Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in
haskell-gargantext
haskell-gargantext
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 166
    • Issues 166
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 11
    • Merge Requests 11
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • gargantext
  • haskell-gargantexthaskell-gargantext
  • Merge Requests
  • !204

Merged
Opened Sep 18, 2023 by Alfredo Di Napoli@AlfredoDiNapoli
  • Report abuse
Report abuse

Flexible policy manager for Rest and GraphQL routes

Fixes #259 (closed).

This beefy MR explores an alternative design for access policy management in Gargantext which might supersede the existing withAccess and withAccessM.

It adds a type-level combinator called PolicyChecked, which can be used to embellish any servant route so that we can bring an AccessPolicyManager in scope which can be used to implement policy checking.

We have two new functions called withPolicy and withPolicyT, which both accepts a BoolExpr AccessCheck, which means we can compose policy checks using the similar boolean API mechanism. For example, the following grants access if the input NodeId matches the one of the logged in user, the authenticated user is the master user or if the node is a descendant of the authenticated user:

nodeChecks :: NodeId -> BoolExpr AccessCheck
nodeChecks nid =
  nodeUser nid `BOr` nodeSuper nid `BOr` nodeDescendant nid

I've also added tests to check that we are indeed protecting the endpoints as expected.

N.B. I haven't added this check for all the endpoint, that should follow in future MRs. However, I have left in place the old withAccess, which might be eventually superseded.

Edited Oct 02, 2023 by Alfredo Di Napoli

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b adinapoli/issue-259 origin/adinapoli/issue-259

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/dev
git merge --no-ff adinapoli/issue-259

Step 4. Push the result of the merge to GitLab

git push origin dev

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 7
  • Commits 16
  • Pipelines 13
  • Changes 61
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: gargantext/haskell-gargantext!204

Revert this commit

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this commit

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.