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
b59a7d9c
Commit
b59a7d9c
authored
Nov 11, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add nodeWriteChecks to some GQL mutators
parent
48bab856
Pipeline
#6958
passed with stages
in 33 minutes and 12 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
11 deletions
+20
-11
gargantext.cabal
gargantext.cabal
+1
-0
GraphQL.hs
src/Gargantext/API/GraphQL.hs
+1
-1
Context.hs
src/Gargantext/API/GraphQL/Context.hs
+12
-6
PolicyCheck.hs
src/Gargantext/API/GraphQL/PolicyCheck.hs
+6
-4
No files found.
gargantext.cabal
View file @
b59a7d9c
...
...
@@ -544,6 +544,7 @@ library
, monad-control ^>= 1.0.3.1
, monad-logger ^>= 0.3.36
, morpheus-graphql >= 0.24.3 && < 0.25
, morpheus-graphql-app >= 0.24.3 && < 0.25
, morpheus-graphql-server >= 0.24.3 && < 0.25
, morpheus-graphql-subscriptions >= 0.24.3 && < 0.25
, mtl ^>= 2.2.2
...
...
src/Gargantext/API/GraphQL.hs
View file @
b59a7d9c
...
...
@@ -129,7 +129,7 @@ rootResolver authenticatedUser policyManager =
,
update_user_epo_api_user
=
GQLUser
.
updateUserEPOAPIUser
,
update_user_epo_api_token
=
GQLUser
.
updateUserEPOAPIToken
,
delete_team_membership
=
GQLTeam
.
deleteTeamMembership
,
update_node_context_category
=
GQLCTX
.
updateNodeContextCategory
}
,
update_node_context_category
=
GQLCTX
.
updateNodeContextCategory
authenticatedUser
policyManager
}
}
-- | Main GraphQL "app".
...
...
src/Gargantext/API/GraphQL/Context.hs
View file @
b59a7d9c
...
...
@@ -23,9 +23,12 @@ import Data.Morpheus.Types
,
QUERY
)
import
Data.Text
(
pack
,
unpack
)
import
qualified
Data.Text
as
Text
import
Data.Text
qualified
as
Text
import
Data.Time.Format.ISO8601
(
iso8601Show
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Auth.PolicyCheck
(
nodeWriteChecks
,
AccessPolicyManager
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.GraphQL.PolicyCheck
(
withPolicy
)
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.Core.Types.Search
(
HyperdataRow
(
..
),
toHyperdataRow
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
)
...
...
@@ -219,8 +222,11 @@ toHyperdataRowDocumentGQL hyperdata =
HyperdataRowContact
{
}
->
Nothing
updateNodeContextCategory
::
(
CmdCommon
env
)
=>
NodeContextCategoryMArgs
->
GqlM'
e
env
[
Int
]
updateNodeContextCategory
NodeContextCategoryMArgs
{
context_id
,
node_id
,
category
}
=
do
_
<-
lift
$
DNC
.
updateNodeContextCategory
(
UnsafeMkContextId
context_id
)
(
UnsafeMkNodeId
node_id
)
category
pure
[
1
]
=>
AuthenticatedUser
->
AccessPolicyManager
->
NodeContextCategoryMArgs
->
GqlM'
e
env
[
Int
]
updateNodeContextCategory
autUser
mgr
NodeContextCategoryMArgs
{
context_id
,
node_id
,
category
}
=
withPolicy
autUser
mgr
(
nodeWriteChecks
$
UnsafeMkNodeId
node_id
)
$
do
void
$
lift
$
DNC
.
updateNodeContextCategory
(
UnsafeMkContextId
context_id
)
(
UnsafeMkNodeId
node_id
)
category
pure
[
1
]
src/Gargantext/API/GraphQL/PolicyCheck.hs
View file @
b59a7d9c
...
...
@@ -7,16 +7,18 @@ import Control.Monad.Except (MonadError(..), MonadTrans(..))
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Auth.PolicyCheck
(
BoolExpr
,
AccessCheck
,
AccessPolicyManager
(
..
),
AccessResult
(
..
))
import
Gargantext.API.Errors.Types
(
BackendInternalError
(
..
)
)
import
Gargantext.API.GraphQL.Types
(
GqlM
)
import
Gargantext.Core.Config
(
HasConfig
)
import
Gargantext.Database.Prelude
(
HasConnectionPool
)
import
Data.Morpheus.Types
(
ResolverO
)
import
Data.Morpheus.App.Internal.Resolving
(
LiftOperation
)
import
Gargantext.API.Prelude
(
GargM
)
withPolicy
::
(
HasConnectionPool
env
,
HasConfig
env
)
withPolicy
::
(
HasConnectionPool
env
,
HasConfig
env
,
LiftOperation
op
)
=>
AuthenticatedUser
->
AccessPolicyManager
->
BoolExpr
AccessCheck
->
GqlM
e
env
a
->
GqlM
e
env
a
->
ResolverO
op
e
(
GargM
env
BackendInternalError
)
a
->
ResolverO
op
e
(
GargM
env
BackendInternalError
)
a
withPolicy
ur
mgr
checks
m
=
case
mgr
of
AccessPolicyManager
{
runAccessPolicy
}
->
do
res
<-
lift
$
runAccessPolicy
ur
checks
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment