Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
157
Issues
157
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
2b67dad8
Commit
2b67dad8
authored
Jun 04, 2024
by
Alexandre Delanoë
1
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/adinapoli/issue-271' into dev
parents
0a4a4d95
406b3e58
Changes
97
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
97 changed files
with
2046 additions
and
2485 deletions
+2046
-2485
Main.hs
bin/gargantext-invitations/Main.hs
+2
-1
update-project-dependencies
bin/update-project-dependencies
+2
-2
cabal.project
cabal.project
+2
-2
cabal.project.freeze
cabal.project.freeze
+1
-1
gargantext.cabal
gargantext.cabal
+24
-4
API.hs
src/Gargantext/API.hs
+16
-11
Auth.hs
src/Gargantext/API/Admin/Auth.hs
+46
-34
Types.hs
src/Gargantext/API/Admin/Auth/Types.hs
+39
-4
EnvTypes.hs
src/Gargantext/API/Admin/EnvTypes.hs
+4
-1
Types.hs
src/Gargantext/API/Admin/Orchestrator/Types.hs
+3
-2
PolicyCheck.hs
src/Gargantext/API/Auth/PolicyCheck.hs
+7
-0
Context.hs
src/Gargantext/API/Context.hs
+14
-15
Count.hs
src/Gargantext/API/Count.hs
+6
-132
Types.hs
src/Gargantext/API/Count/Types.hs
+130
-0
Members.hs
src/Gargantext/API/Members.hs
+5
-10
Metrics.hs
src/Gargantext/API/Metrics.hs
+27
-69
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+6
-209
List.hs
src/Gargantext/API/Ngrams/List.hs
+19
-45
Types.hs
src/Gargantext/API/Ngrams/Types.hs
+7
-4
Node.hs
src/Gargantext/API/Node.hs
+110
-218
Contact.hs
src/Gargantext/API/Node/Contact.hs
+14
-44
Types.hs
src/Gargantext/API/Node/Contact/Types.hs
+31
-0
Annuaire.hs
src/Gargantext/API/Node/Corpus/Annuaire.hs
+0
-11
Export.hs
src/Gargantext/API/Node/Corpus/Export.hs
+40
-40
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+0
-27
Export.hs
src/Gargantext/API/Node/Document/Export.hs
+15
-10
Types.hs
src/Gargantext/API/Node/Document/Export/Types.hs
+4
-10
DocumentUpload.hs
src/Gargantext/API/Node/DocumentUpload.hs
+6
-43
Types.hs
src/Gargantext/API/Node/DocumentUpload/Types.hs
+39
-0
DocumentsFromWriteNodes.hs
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
+6
-24
Types.hs
src/Gargantext/API/Node/DocumentsFromWriteNodes/Types.hs
+23
-0
File.hs
src/Gargantext/API/Node/File.hs
+10
-44
Types.hs
src/Gargantext/API/Node/File/Types.hs
+36
-0
FrameCalcUpload.hs
src/Gargantext/API/Node/FrameCalcUpload.hs
+6
-25
Types.hs
src/Gargantext/API/Node/FrameCalcUpload/Types.hs
+20
-0
Get.hs
src/Gargantext/API/Node/Get.hs
+0
-16
New.hs
src/Gargantext/API/Node/New.hs
+6
-29
Types.hs
src/Gargantext/API/Node/New/Types.hs
+27
-0
Export.hs
src/Gargantext/API/Node/Phylo/Export.hs
+11
-7
Types.hs
src/Gargantext/API/Node/Phylo/Export/Types.hs
+1
-10
Share.hs
src/Gargantext/API/Node/Share.hs
+5
-33
Types.hs
src/Gargantext/API/Node/Share/Types.hs
+25
-0
ShareURL.hs
src/Gargantext/API/Node/ShareURL.hs
+8
-12
Types.hs
src/Gargantext/API/Node/Types.hs
+31
-0
Update.hs
src/Gargantext/API/Node/Update.hs
+7
-86
Types.hs
src/Gargantext/API/Node/Update/Types.hs
+85
-0
Prelude.hs
src/Gargantext/API/Prelude.hs
+3
-0
Types.hs
src/Gargantext/API/Public/Types.hs
+46
-0
Routes.hs
src/Gargantext/API/Routes.hs
+14
-272
Named.hs
src/Gargantext/API/Routes/Named.hs
+50
-11
Annuaire.hs
src/Gargantext/API/Routes/Named/Annuaire.hs
+22
-0
Contact.hs
src/Gargantext/API/Routes/Named/Contact.hs
+2
-10
Context.hs
src/Gargantext/API/Routes/Named/Context.hs
+5
-2
Corpus.hs
src/Gargantext/API/Routes/Named/Corpus.hs
+5
-7
Count.hs
src/Gargantext/API/Routes/Named/Count.hs
+1
-1
Document.hs
src/Gargantext/API/Routes/Named/Document.hs
+15
-82
EKG.hs
src/Gargantext/API/Routes/Named/EKG.hs
+18
-0
File.hs
src/Gargantext/API/Routes/Named/File.hs
+2
-2
FrameCalc.hs
src/Gargantext/API/Routes/Named/FrameCalc.hs
+8
-4
List.hs
src/Gargantext/API/Routes/Named/List.hs
+17
-9
Node.hs
src/Gargantext/API/Routes/Named/Node.hs
+19
-104
Private.hs
src/Gargantext/API/Routes/Named/Private.hs
+43
-20
Public.hs
src/Gargantext/API/Routes/Named/Public.hs
+10
-2
Search.hs
src/Gargantext/API/Routes/Named/Search.hs
+2
-85
Share.hs
src/Gargantext/API/Routes/Named/Share.hs
+2
-26
Table.hs
src/Gargantext/API/Routes/Named/Table.hs
+10
-40
Viz.hs
src/Gargantext/API/Routes/Named/Viz.hs
+13
-52
Types.hs
src/Gargantext/API/Routes/Types.hs
+9
-2
Search.hs
src/Gargantext/API/Search.hs
+9
-99
Types.hs
src/Gargantext/API/Search/Types.hs
+90
-0
Named.hs
src/Gargantext/API/Server/Named.hs
+35
-42
EKG.hs
src/Gargantext/API/Server/Named/EKG.hs
+50
-0
Ngrams.hs
src/Gargantext/API/Server/Named/Ngrams.hs
+189
-0
Private.hs
src/Gargantext/API/Server/Named/Private.hs
+68
-0
Public.hs
src/Gargantext/API/Server/Named/Public.hs
+22
-79
Viz.hs
src/Gargantext/API/Server/Named/Viz.hs
+34
-0
Swagger.hs
src/Gargantext/API/Swagger.hs
+6
-3
Table.hs
src/Gargantext/API/Table.hs
+11
-52
Types.hs
src/Gargantext/API/Table/Types.hs
+40
-0
ThrowAll.hs
src/Gargantext/API/ThrowAll.hs
+33
-26
Types.hs
src/Gargantext/API/Types.hs
+14
-6
Types.hs
src/Gargantext/API/Viz/Types.hs
+65
-0
API.hs
src/Gargantext/Core/Viz/Graph/API.hs
+5
-52
Types.hs
src/Gargantext/Core/Viz/Graph/Types.hs
+10
-0
API.hs
src/Gargantext/Core/Viz/Phylo/API.hs
+13
-93
stack.yaml
stack.yaml
+5
-4
Authentication.hs
test/Test/API/Authentication.hs
+3
-3
Errors.hs
test/Test/API/Errors.hs
+10
-8
Private.hs
test/Test/API/Private.hs
+10
-11
Routes.hs
test/Test/API/Routes.hs
+70
-25
Setup.hs
test/Test/API/Setup.hs
+1
-1
UpdateList.hs
test/Test/API/UpdateList.hs
+6
-6
Distance.hs
test/Test/Graph/Distance.hs
+0
-2
JSON.hs
test/Test/Offline/JSON.hs
+1
-2
Types.hs
test/Test/Types.hs
+1
-1
Utils.hs
test/Test/Utils.hs
+1
-2
Crypto.hs
test/Test/Utils/Crypto.hs
+2
-2
No files found.
bin/gargantext-invitations/Main.hs
View file @
2b67dad8
...
...
@@ -24,7 +24,8 @@ import Gargantext.Database.Prelude (CmdRandom)
import
Gargantext.Prelude
import
Gargantext.Prelude.Config
(
readConfig
)
import
Prelude
(
read
)
import
qualified
Gargantext.API.Node.Share
as
Share
import
Gargantext.API.Node.Share.Types
qualified
as
Share
import
Gargantext.API.Node.Share
qualified
as
Share
main
::
IO
()
main
=
do
...
...
bin/update-project-dependencies
View file @
2b67dad8
...
...
@@ -18,8 +18,8 @@ fi
# with the `sha256sum` result calculated on the `cabal.project` and
# `cabal.project.freeze`. This ensures the files stay deterministic so that CI
# cache can kick in.
expected_cabal_project_hash
=
"
0d3f7f5beed88c1afe95e0df8a91080440ba59049f3610bf2343132635038d22
"
expected_cabal_project_freeze_hash
=
"
9b2cac3a02e9b129bd80253fc407782bf10c7ed62ed21be41c720d30ed17ef53
"
expected_cabal_project_hash
=
"
75954432d1b867597b6eff606d22b36e53a18b283464c9c9d309af231a694d6b
"
expected_cabal_project_freeze_hash
=
"
09930a2fa36e4325d46e5d069595d300c6017472f405f8ac67158377816d132a
"
cabal
--store-dir
=
$STORE_DIR
v2-build
--dry-run
cabal2stack
--system-ghc
--allow-newer
--resolver
lts-21.17
--resolver-file
devops/stack/lts-21.17.yaml
-o
stack.yaml
...
...
cabal.project
View file @
2b67dad8
...
...
@@ -51,8 +51,8 @@ source-repository-package
source
-
repository
-
package
type
:
git
location
:
https
://
github
.
com
/
a
lpmestan
/
servant
-
job
.
git
tag
:
b4182487cfe479777c11ca19f3c0d47840b376f
6
location
:
https
://
github
.
com
/
a
dinapoli
/
servant
-
job
.
git
tag
:
74
a3296dfe1f0c4a3ade91336dcc689330e8415
6
source
-
repository
-
package
type
:
git
...
...
cabal.project.freeze
View file @
2b67dad8
...
...
@@ -499,7 +499,7 @@ constraints: any.Cabal ==3.8.1.0,
any.servant-multipart ==0.12.1,
any.servant-multipart-api ==0.12.1,
any.servant-server ==0.20,
any.servant-swagger ==1.
1.11
,
any.servant-swagger ==1.
2
,
any.servant-swagger-ui ==0.3.5.5.0.0,
any.servant-swagger-ui-core ==0.3.5,
any.servant-xml-conduit ==0.1.0.4,
...
...
gargantext.cabal
View file @
2b67dad8
...
...
@@ -113,6 +113,7 @@ library
Gargantext.API.Admin.Settings.CORS
Gargantext.API.Admin.Types
Gargantext.API.Auth.PolicyCheck
Gargantext.API.Count.Types
Gargantext.API.Dev
Gargantext.API.Errors
Gargantext.API.Errors.Class
...
...
@@ -132,18 +133,23 @@ library
Gargantext.API.Node.Corpus.Types
Gargantext.API.Node.Corpus.Update
Gargantext.API.Node.File
Gargantext.API.Node.File.Types
Gargantext.API.Node.Share
Gargantext.API.Node.Share.Types
Gargantext.API.Node.ShareURL
Gargantext.API.Node.Types
Gargantext.API.Node.Update
Gargantext.API.Node.Update.Types
Gargantext.API.Prelude
Gargantext.API.Routes
Gargantext.API.Routes.Named
Gargantext.API.Routes.Named.Annuaire
Gargantext.API.Routes.Named.Contact
Gargantext.API.Routes.Named.Context
Gargantext.API.Routes.Named.Corpus
Gargantext.API.Routes.Named.Count
Gargantext.API.Routes.Named.Document
Gargantext.API.Routes.Named.EKG
Gargantext.API.Routes.Named.File
Gargantext.API.Routes.Named.FrameCalc
Gargantext.API.Routes.Named.List
...
...
@@ -157,6 +163,8 @@ library
Gargantext.API.Routes.Named.Tree
Gargantext.API.Routes.Named.Viz
Gargantext.API.Routes.Types
Gargantext.API.Types
Gargantext.API.Viz.Types
Gargantext.Core
Gargantext.Core.Mail.Types
Gargantext.Core.Methods.Similarities
...
...
@@ -288,6 +296,7 @@ library
Gargantext.API.Metrics
Gargantext.API.Ngrams.NgramsTree
Gargantext.API.Node.Contact
Gargantext.API.Node.Contact.Types
Gargantext.API.Node.Corpus.Annuaire
Gargantext.API.Node.Corpus.Export
Gargantext.API.Node.Corpus.Export.Types
...
...
@@ -299,17 +308,27 @@ library
Gargantext.API.Node.Phylo.Export
Gargantext.API.Node.Phylo.Export.Types
Gargantext.API.Node.DocumentUpload
Gargantext.API.Node.DocumentUpload.Types
Gargantext.API.Node.DocumentsFromWriteNodes
Gargantext.API.Node.DocumentsFromWriteNodes.Types
Gargantext.API.Node.FrameCalcUpload
Gargantext.API.Node.FrameCalcUpload.Types
Gargantext.API.Node.Get
Gargantext.API.Node.New
Gargantext.API.Public
Gargantext.API.Node.New.Types
Gargantext.API.Public.Types
Gargantext.API.Search
Gargantext.API.Server
Gargantext.API.Search.Types
Gargantext.API.Server.Named
Gargantext.API.Server.Named.EKG
Gargantext.API.Server.Named.Ngrams
Gargantext.API.Server.Named.Private
Gargantext.API.Server.Named.Public
Gargantext.API.Server.Named.Viz
Gargantext.API.Swagger
Gargantext.API.Table
Gargantext.API.Table.Types
Gargantext.API.ThrowAll
Gargantext.API.Types
Gargantext.Core.Ext.IMT
Gargantext.Core.Ext.IMTUser
Gargantext.Core.Flow.Ngrams
...
...
@@ -622,8 +641,9 @@ library
, servant-job >= 0.2.0.0
, servant-multipart ^>= 0.12.1
, servant-server >= 0.18.3 && < 0.20
, servant-swagger
^>= 1.1.10
, servant-swagger
>= 1.2
, servant-swagger-ui ^>= 0.3.5.3.5.0
, servant-swagger-ui-core >= 0.3.5
, servant-xml-conduit >= 0.1.0.4
, simple-reflect ^>= 0.3.3
, singletons ^>= 2.7
...
...
src/Gargantext/API.hs
View file @
2b67dad8
...
...
@@ -46,10 +46,11 @@ import Gargantext.API.Admin.EnvTypes (Env, Mode(..))
import
Gargantext.API.Admin.Settings
(
newEnv
)
import
Gargantext.API.Admin.Settings.CORS
import
Gargantext.API.Admin.Types
(
FireWall
(
..
),
PortNumber
,
cookieSettings
,
jwtSettings
,
settings
,
corsSettings
)
import
Gargantext.API.EKG
import
Gargantext.API.
Routes.Named.
EKG
import
Gargantext.API.Middleware
(
logStdoutDevSanitised
)
import
Gargantext.API.Routes
import
Gargantext.API.Server
(
server
)
import
Gargantext.API.Routes.Named
(
API
)
import
Gargantext.API.Server.Named
(
server
)
import
Gargantext.API.Server.Named.EKG
import
Gargantext.Database.Prelude
qualified
as
DB
import
Gargantext.Prelude
hiding
(
putStrLn
)
import
Gargantext.System.Logging
...
...
@@ -166,11 +167,12 @@ makeGargMiddleware crsSettings mode = do
makeApp
::
Env
->
IO
Application
makeApp
env
=
do
serv
<-
server
env
(
ekgStore
,
ekgMid
)
<-
newEkgStore
api
ekgDir
<-
(
</>
"ekg-assets"
)
<$>
getDataDir
pure
$
ekgMid
$
serveWithContext
apiWithEkg
cfg
(
ekgServer
ekgDir
ekgStore
:<|>
serv
)
(
WithEkg
{
ekgAPI
=
ekgServer
ekgDir
ekgStore
,
wrappedAPI
=
server
env
})
where
cfg
::
Servant
.
Context
AuthContext
cfg
=
env
^.
settings
.
jwtSettings
...
...
@@ -178,12 +180,15 @@ makeApp env = do
:.
EmptyContext
---------------------------------------------------------------------
api
::
Proxy
API
api
::
Proxy
(
NamedRoutes
API
)
api
=
Proxy
apiWithEkg
::
Proxy
(
EkgAPI
:<|>
API
)
apiWithEkg
=
Proxy
apiGarg
::
Proxy
GargAPI
apiGarg
=
Proxy
---------------------------------------------------------------------
data
WithEkg
api
mode
=
WithEkg
{
ekgAPI
::
mode
:-
NamedRoutes
EkgAPI
,
wrappedAPI
::
mode
:-
NamedRoutes
api
}
deriving
Generic
apiWithEkg
::
Proxy
(
NamedRoutes
(
WithEkg
API
))
apiWithEkg
=
Proxy
src/Gargantext/API/Admin/Auth.hs
View file @
2b67dad8
...
...
@@ -27,41 +27,42 @@ And you have the main viz
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
module
Gargantext.API.Admin.Auth
(
auth
,
withPolicy
,
withPolicyT
,
withNamedPolicyT
,
forgotPassword
,
forgotPasswordAsync
,
withAccess
,
ForgotPasswordAPI
,
withNamedAccess
,
ForgotPasswordAsyncParams
,
ForgotPasswordAsyncAPI
)
where
import
Control.Lens
(
view
,
(
#
))
import
Data.Aeson
import
Data.Swagger
(
ToSchema
(
..
))
import
Data.Text
qualified
as
Text
import
Data.Text.Lazy.Encoding
qualified
as
LE
import
Data.UUID
(
UUID
,
fromText
,
toText
)
import
Data.UUID.V4
(
nextRandom
)
import
Gargantext.API.Admin.Auth.Types
import
Gargantext.API.Admin.EnvTypes
(
GargJob
(
..
),
Env
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Admin.Orchestrator.Types
(
AsyncJobs
(
..
)
)
import
Gargantext.API.Admin.Types
import
Gargantext.API.Auth.PolicyCheck
import
Gargantext.API.Prelude
(
authenticationError
,
HasServerError
,
GargServerC
,
GargServer
,
_ServerError
,
GargM
)
import
Gargantext.API.Errors
import
Gargantext.API.Prelude
(
authenticationError
,
HasServerError
,
GargServerC
,
_ServerError
,
GargM
,
IsGargServer
)
import
Gargantext.Core.Mail
(
MailModel
(
..
),
mail
)
import
Gargantext.Core.Mail.Types
(
mailSettings
)
import
Gargantext.Core.Types.Individu
(
User
(
..
),
Username
,
GargPassword
(
..
))
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Action.User.New
(
guessUserName
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
))
import
Gargantext.Database.Prelude
(
Cmd
'
,
CmdCommon
,
DbCmd
'
)
import
Gargantext.Database.Admin.Types.Node
(
UserId
)
import
Gargantext.Database.Prelude
(
Cmd
'
,
CmdCommon
,
DbCmd
'
)
import
Gargantext.Database.Query.Table.User
import
Gargantext.Database.Query.Tree
(
isDescendantOf
,
isIn
)
import
Gargantext.Database.Query.Tree.Root
(
getRoot
)
...
...
@@ -71,8 +72,10 @@ import Gargantext.Prelude.Crypto.Auth qualified as Auth
import
Gargantext.Prelude.Crypto.Pass.User
(
gargPass
)
import
Gargantext.Utils.Jobs
(
serveJobsAPI
,
MonadJobStatus
(
..
))
import
Servant
import
Servant.API.Generic
()
import
Servant.Auth.Server
import
Gargantext.API.Errors
import
Servant.Server.Generic
import
qualified
Gargantext.API.Routes.Named
as
Named
---------------------------------------------------
...
...
@@ -163,10 +166,23 @@ withAccess p _ ur id = hoistServer p f
f
::
forall
a
.
m
a
->
m
a
f
=
withAccessM
ur
id
withNamedAccess
::
forall
env
err
m
routes
.
(
IsGargServer
env
err
m
,
HasServer
(
NamedRoutes
routes
)
'[
]
)
=>
AuthenticatedUser
->
PathId
->
routes
(
AsServerT
m
)
->
routes
(
AsServerT
m
)
withNamedAccess
ur
pathId
=
hoistServer
(
Proxy
@
(
NamedRoutes
routes
))
f
where
f
::
forall
a
.
m
a
->
m
a
f
=
withAccessM
ur
pathId
-- | Given the 'AuthenticatedUser', a policy check and a function that returns an @a@,
-- it runs the underlying policy check to ensure that the resource is returned only to
-- who is entitled to see it.
withPolicy
::
GargServerC
env
BackendInternalError
m
withPolicy
::
IsGargServer
env
BackendInternalError
m
=>
AuthenticatedUser
->
BoolExpr
AccessCheck
->
m
a
...
...
@@ -179,8 +195,21 @@ withPolicy ur checks m mgr = case mgr of
Allow
->
m
Deny
err
->
throwError
$
InternalServerError
$
err
-- FIXME(adn) the types are wrong.
withNamedPolicyT
::
forall
env
m
routes
.
(
IsGargServer
env
BackendInternalError
m
,
HasServer
(
NamedRoutes
routes
)
'[
]
)
=>
AuthenticatedUser
->
BoolExpr
AccessCheck
->
routes
(
AsServerT
m
)
->
AccessPolicyManager
->
routes
(
AsServerT
m
)
withNamedPolicyT
ur
checks
m
mgr
=
hoistServer
(
Proxy
@
(
NamedRoutes
routes
))
(
\
n
->
withPolicy
ur
checks
n
mgr
)
m
withPolicyT
::
forall
env
m
api
.
(
GargServerC
env
BackendInternalError
m
IsGargServer
env
BackendInternalError
m
,
HasServer
api
'[
]
)
=>
Proxy
api
...
...
@@ -202,26 +231,12 @@ User can invite User in Team as NodeNode only if Team in his parents.
All users can access to the Team folder as if they were owner.
-}
newtype
ForgotPasswordAsyncParams
=
ForgotPasswordAsyncParams
{
email
::
Text
}
deriving
(
Generic
,
Show
)
instance
FromJSON
ForgotPasswordAsyncParams
where
parseJSON
=
genericParseJSON
defaultOptions
instance
ToJSON
ForgotPasswordAsyncParams
where
toJSON
=
genericToJSON
defaultOptions
instance
ToSchema
ForgotPasswordAsyncParams
type
ForgotPasswordAPI
=
Summary
"Forgot password POST API"
:>
ReqBody
'[
J
SON
]
ForgotPasswordRequest
:>
Post
'[
J
SON
]
ForgotPasswordResponse
:<|>
Summary
"Forgot password GET API"
:>
QueryParam
"uuid"
Text
:>
Get
'[
J
SON
]
ForgotPasswordGet
forgotPassword
::
GargServer
ForgotPasswordAPI
forgotPassword
::
IsGargServer
env
err
m
=>
Named
.
ForgotPasswordAPI
(
AsServerT
m
)
-- => ForgotPasswordRequest -> Cmd' env err ForgotPasswordResponse
forgotPassword
=
forgotPasswordPost
:<|>
forgotPasswordGet
forgotPassword
=
Named
.
ForgotPasswordAPI
{
forgotPasswordPostEp
=
forgotPasswordPost
,
forgotPasswordGetEp
=
forgotPasswordGet
}
forgotPasswordPost
::
(
CmdCommon
env
)
=>
ForgotPasswordRequest
->
Cmd'
env
err
ForgotPasswordResponse
...
...
@@ -310,11 +325,8 @@ generateForgotPasswordUUID = do
-- NOTE THe async endpoint is better for the "forget password"
-- request, because the delay in email sending etc won't reveal to
-- malicious users emails of our users in the db
type
ForgotPasswordAsyncAPI
=
Summary
"Forgot password asnc"
:>
AsyncJobs
JobLog
'[
J
SON
]
ForgotPasswordAsyncParams
JobLog
forgotPasswordAsync
::
ServerT
ForgotPasswordAsyncAPI
(
GargM
Env
BackendInternalError
)
forgotPasswordAsync
=
forgotPasswordAsync
::
Named
.
ForgotPasswordAsyncAPI
(
AsServerT
(
GargM
Env
BackendInternalError
))
forgotPasswordAsync
=
Named
.
ForgotPasswordAsyncAPI
$
AsyncJobs
$
serveJobsAPI
ForgotPasswordJob
$
\
jHandle
p
->
forgotPasswordAsync'
p
jHandle
forgotPasswordAsync'
::
(
FlowCmdM
env
err
m
,
MonadJobStatus
m
)
...
...
src/Gargantext/API/Admin/Auth/Types.hs
View file @
2b67dad8
...
...
@@ -11,9 +11,36 @@ Portability : POSIX
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.API.Admin.Auth.Types
where
import
qualified
Data.Aeson.TH
as
JSON
(
-- * Types
AuthRequest
(
..
)
,
AuthResponse
(
..
)
,
Token
,
TreeId
,
CheckAuth
(
..
)
,
AuthenticatedUser
(
..
)
,
AuthContext
,
AuthenticationError
(
..
)
,
PathId
(
..
)
,
Email
,
Password
,
ForgotPasswordRequest
(
..
)
,
ForgotPasswordResponse
(
..
)
,
ForgotPasswordAsyncParams
(
..
)
,
ForgotPasswordGet
(
..
)
-- * Lenses
,
auth_node_id
,
auth_user_id
,
authRes_token
,
authRes_tree_id
,
authRes_user_id
-- * Combinators
)
where
import
Crypto.JWT
qualified
as
Jose
import
Data.Aeson.TH
qualified
as
JSON
import
Data.Aeson.Types
(
genericParseJSON
,
defaultOptions
,
genericToJSON
)
import
Data.List
(
tail
)
import
Data.Swagger
(
ToSchema
(
..
),
genericDeclareNamedSchema
)
import
Gargantext.Core.Types.Individu
(
Username
,
GargPassword
(
..
),
arbitraryUsername
,
arbitraryPassword
)
...
...
@@ -23,7 +50,6 @@ import Gargantext.Prelude hiding (reverse)
import
Servant.Auth.Server
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
qualified
Crypto.JWT
as
Jose
---------------------------------------------------
...
...
@@ -106,6 +132,15 @@ data ForgotPasswordGet = ForgotPasswordGet {_fpGet_password :: Password}
instance
ToSchema
ForgotPasswordGet
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_fpGet_"
)
newtype
ForgotPasswordAsyncParams
=
ForgotPasswordAsyncParams
{
email
::
Text
}
deriving
(
Generic
,
Show
)
instance
FromJSON
ForgotPasswordAsyncParams
where
parseJSON
=
genericParseJSON
defaultOptions
instance
ToJSON
ForgotPasswordAsyncParams
where
toJSON
=
genericToJSON
defaultOptions
instance
ToSchema
ForgotPasswordAsyncParams
--
-- Lenses
--
...
...
src/Gargantext/API/Admin/EnvTypes.hs
View file @
2b67dad8
...
...
@@ -34,7 +34,7 @@ import Gargantext.API.Admin.Orchestrator.Types
import
Gargantext.API.Admin.Types
import
Gargantext.API.Errors.Types
import
Gargantext.API.Job
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Prelude
(
GargM
,
IsGargServer
)
import
Gargantext.Core.Mail.Types
(
HasMail
,
mailSettings
)
import
Gargantext.Core.NLP
(
NLPServerMap
,
HasNLPServer
(
..
))
import
Gargantext.Core.NodeStory
...
...
@@ -322,3 +322,6 @@ instance HasMail DevEnv where
instance
HasNLPServer
DevEnv
where
nlpServer
=
dev_env_nlp
instance
IsGargServer
Env
BackendInternalError
(
GargM
Env
BackendInternalError
)
src/Gargantext/API/Admin/Orchestrator/Types.hs
View file @
2b67dad8
...
...
@@ -136,5 +136,6 @@ type ScrapersEnv = JobEnv JobLog JobLog
type
ScraperAPI
=
AsyncJobsAPI
JobLog
ScraperInput
JobLog
------------------------------------------------------------------------
type
AsyncJobs
event
ctI
input
output
=
AsyncJobsAPI'
'U
n
safe
'S
a
fe
ctI
'[
J
SON
]
Maybe
event
input
output
data
AsyncJobs
event
ctI
input
output
mode
=
AsyncJobs
{
asyncJobsAPI'
::
mode
:-
AsyncJobsAPI'
'U
n
safe
'S
a
fe
ctI
'[
J
SON
]
Maybe
event
input
output
}
deriving
Generic
src/Gargantext/API/Auth/PolicyCheck.hs
View file @
2b67dad8
...
...
@@ -39,6 +39,7 @@ import Servant.Ekg
import
Servant.Server.Internal.Delayed
import
Servant.Server.Internal.DelayedIO
import
qualified
Servant.Swagger
as
Swagger
import
Servant.Client.Core
-------------------------------------------------------------------------------
-- Types
...
...
@@ -196,6 +197,12 @@ instance HasEndpoint sub => HasEndpoint (PolicyChecked sub) where
getEndpoint
_
=
getEndpoint
(
Proxy
::
Proxy
sub
)
enumerateEndpoints
_
=
enumerateEndpoints
(
Proxy
::
Proxy
sub
)
instance
HasClient
m
sub
=>
HasClient
m
(
PolicyChecked
sub
)
where
type
Client
m
(
PolicyChecked
sub
)
=
AccessPolicyManager
->
Client
m
sub
clientWithRoute
m
_
req
_mgr
=
clientWithRoute
m
(
Proxy
::
Proxy
sub
)
req
hoistClientMonad
pm
_
nt
cl
=
hoistClientMonad
pm
(
Proxy
::
Proxy
sub
)
nt
.
cl
-------------------------------------------------------------------------------
-- Utility functions
-------------------------------------------------------------------------------
...
...
src/Gargantext/API/Context.hs
View file @
2b67dad8
...
...
@@ -23,28 +23,27 @@ import Prelude
import
Data.Aeson
(
FromJSON
,
ToJSON
)
import
Servant
import
Gargantext.API.Admin.Auth
(
withAccess
)
import
Gargantext.API.Admin.Auth
(
with
Named
Access
)
import
Gargantext.API.Admin.Auth.Types
(
PathId
(
..
),
AuthenticatedUser
)
import
Gargantext.API.Prelude
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
JSONB
)
import
Gargantext.Database.Query.Table.Context
import
Servant.Server.Generic
(
AsServerT
)
import
Gargantext.API.Routes.Named.Context
qualified
as
Named
-------------------------------------------------------------------
-- TODO use Context instead of Node
type
ContextAPI
a
=
Get
'[
J
SON
]
(
Node
a
)
------------------------------------------------------------------------
-- TODO NodeAPI -> ContextAPI
contextAPI
::
forall
proxy
a
.
(
JSONB
a
,
FromJSON
a
,
ToJSON
a
)
=>
proxy
a
->
AuthenticatedUser
->
ContextId
->
GargServer
(
ContextAPI
a
)
contextAPI
p
uId
id'
=
withAccess
(
Proxy
::
Proxy
(
ContextAPI
a
))
Proxy
uId
(
PathNode
$
contextId2NodeId
id'
)
contextAPI'
contextAPI
::
(
IsGargServer
env
err
m
,
JSONB
a
,
FromJSON
a
,
ToJSON
a
)
=>
Proxy
a
->
AuthenticatedUser
->
ContextId
->
Named
.
ContextAPI
a
(
AsServerT
m
)
contextAPI
p
uId
id'
=
withNamedAccess
uId
(
PathNode
$
contextId2NodeId
id'
)
contextAPI'
where
contextAPI'
::
GargServer
(
ContextAPI
a
)
contextAPI'
=
getContextWith
id'
p
contextAPI'
=
Named
.
ContextAPI
$
getContextWith
id'
p
src/Gargantext/API/Count.hs
View file @
2b67dad8
...
...
@@ -17,143 +17,17 @@ Count API part of Gargantext.
{-# LANGUAGE DeriveAnyClass #-}
module
Gargantext.API.Count
(
CountAPI
,
Scraper
(
..
)
,
QueryBool
(
..
)
,
Query
(
..
)
,
Message
(
..
)
,
Code
,
Error
,
Errors
,
Counts
(
..
)
,
Count
(
..
)
-- * functions
,
count
,
scrapers
countAPI
)
where
import
Data.Swagger
(
ToSchema
(
..
),
genericDeclareNamedSchema
)
import
Data.Text
(
pack
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.API.Count.Types
import
Gargantext.API.Routes.Named.Count
qualified
as
Named
import
Gargantext.Prelude
import
Servant
(
JSON
,
Post
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
(
..
))
import
Servant.Server.Generic
(
AsServerT
)
-----------------------------------------------------------------------
-- TODO-ACCESS: CanCount
-- TODO-EVENTS: No events as this is a read only query.
type
CountAPI
=
Post
'[
J
SON
]
Counts
-----------------------------------------------------------------------
data
Scraper
=
Pubmed
|
Hal
|
IsTex
|
Isidore
deriving
(
Eq
,
Show
,
Generic
,
Enum
,
Bounded
)
scrapers
::
[
Scraper
]
scrapers
=
[
minBound
..
maxBound
]
instance
FromJSON
Scraper
instance
ToJSON
Scraper
instance
Arbitrary
Scraper
where
arbitrary
=
elements
scrapers
instance
ToSchema
Scraper
-----------------------------------------------------------------------
data
QueryBool
=
QueryBool
Text
deriving
(
Eq
,
Show
,
Generic
)
queries
::
[
QueryBool
]
queries
=
[
QueryBool
(
pack
"(X OR X') AND (Y OR Y') NOT (Z OR Z')"
)]
--queries = [QueryBool (pack "(X + X') * (Y + Y') - (Z + Z')")]
instance
Arbitrary
QueryBool
where
arbitrary
=
elements
queries
instance
FromJSON
QueryBool
instance
ToJSON
QueryBool
instance
ToSchema
QueryBool
-----------------------------------------------------------------------
data
Query
=
Query
{
query_query
::
QueryBool
,
query_name
::
Maybe
[
Scraper
]
}
deriving
(
Eq
,
Show
,
Generic
)
instance
FromJSON
Query
instance
ToJSON
Query
instance
Arbitrary
Query
where
arbitrary
=
elements
[
Query
q
(
Just
n
)
|
q
<-
queries
,
n
<-
take
10
$
permutations
scrapers
]
instance
ToSchema
Query
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"query_"
)
-----------------------------------------------------------------------
type
Code
=
Integer
type
Error
=
Text
type
Errors
=
[
Error
]
-----------------------------------------------------------------------
data
Message
=
Message
Code
Errors
deriving
(
Eq
,
Show
,
Generic
)
toMessage
::
[(
Code
,
Errors
)]
->
[
Message
]
toMessage
=
map
(
\
(
c
,
err
)
->
Message
c
err
)
messages
::
[
Message
]
messages
=
toMessage
$
[
(
400
,
[
"Ill formed query "
])
,
(
300
,
[
"API connexion error "
])
,
(
300
,
[
"Internal Gargantext Error "
])
]
<>
take
10
(
repeat
(
200
,
[
""
]))
instance
Arbitrary
Message
where
arbitrary
=
elements
messages
instance
ToSchema
Message
-----------------------------------------------------------------------
data
Counts
=
Counts
{
results
::
[
Either
Message
Count
]
}
deriving
(
Eq
,
Show
,
Generic
)
instance
Arbitrary
Counts
where
arbitrary
=
elements
[
Counts
[
Right
(
Count
Pubmed
(
Just
20
))
,
Right
(
Count
IsTex
(
Just
150
))
,
Right
(
Count
Hal
(
Just
150
))
]
]
instance
ToSchema
Counts
-----------------------------------------------------------------------
data
Count
=
Count
{
count_name
::
Scraper
,
count_count
::
Maybe
Int
}
deriving
(
Eq
,
Show
,
Generic
)
instance
ToSchema
Count
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"count_"
)
--instance Arbitrary Count where
-- arbitrary = Count <$> arbitrary <*> arbitrary <*> arbitrary
-----------------------------------------------------------------------
count
::
Monad
m
=>
Query
->
m
Counts
count
_
=
undefined
--
-- JSON instances
--
instance
FromJSON
Message
instance
ToJSON
Message
$
(
deriveJSON
(
unPrefix
"count_"
)
''
C
ount
)
instance
FromJSON
Counts
instance
ToJSON
Counts
countAPI
::
Monad
m
=>
Query
->
Named
.
CountAPI
(
AsServerT
m
)
countAPI
_
=
Named
.
CountAPI
undefined
src/Gargantext/API/Count/Types.hs
0 → 100644
View file @
2b67dad8
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.API.Count.Types
(
Scraper
(
..
)
,
QueryBool
(
..
)
,
Query
(
..
)
,
Message
(
..
)
,
Code
,
Error
,
Errors
,
Counts
(
..
)
,
Count
(
..
)
-- * functions
,
scrapers
)
where
import
Data.Swagger
(
ToSchema
(
..
),
genericDeclareNamedSchema
)
import
Data.Text
(
pack
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Prelude
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
(
..
))
-----------------------------------------------------------------------
data
Scraper
=
Pubmed
|
Hal
|
IsTex
|
Isidore
deriving
(
Eq
,
Show
,
Generic
,
Enum
,
Bounded
)
scrapers
::
[
Scraper
]
scrapers
=
[
minBound
..
maxBound
]
instance
FromJSON
Scraper
instance
ToJSON
Scraper
instance
Arbitrary
Scraper
where
arbitrary
=
elements
scrapers
instance
ToSchema
Scraper
-----------------------------------------------------------------------
data
QueryBool
=
QueryBool
Text
deriving
(
Eq
,
Show
,
Generic
)
queries
::
[
QueryBool
]
queries
=
[
QueryBool
(
pack
"(X OR X') AND (Y OR Y') NOT (Z OR Z')"
)]
--queries = [QueryBool (pack "(X + X') * (Y + Y') - (Z + Z')")]
instance
Arbitrary
QueryBool
where
arbitrary
=
elements
queries
instance
FromJSON
QueryBool
instance
ToJSON
QueryBool
instance
ToSchema
QueryBool
-----------------------------------------------------------------------