Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add granular permissions to the realm tree #1097

Merged
merged 12 commits into from
Feb 14, 2024

Conversation

owi92
Copy link
Member

@owi92 owi92 commented Feb 5, 2024

This allows restricting editing permissions to users and groups of users as discussed in #1049.
There are two "levels" of access:

  • moderate: Users can add subpages and edit content and page settings (excluding permissions and so called "danger zone" things like deleting the page or renaming its path)
  • admin: Everything a moderator can do, but including editing permissions and danger zone things

Permissions are inherited down to every subrealm of a specific realm but can be expanded on in these subrealms. It is however not possible to remove or "downgrade" the access level of an inherited entry, so any user included in a parent realm's access list has at least the same access level for that parent realm's children.

Closes #1049
(Can be reviewed commit by commit)

@github-actions github-actions bot temporarily deployed to test-deployment-pr1097 February 5, 2024 10:04 Destroyed
@owi92 owi92 added the changelog:user User facing changes label Feb 5, 2024
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First half of my review. I reviewed all backend changes, but only a few of the frontend changes. Will post that review later.

backend/src/db/migrations/30-realm-permissions.sql Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mutations.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok now I tested this on the test deployment, but also some general comments.

  • I like that ROLE_TOBIRA_MODERATOR is not used anymore. If you want the old behavior, you can just add that known group and then add it to the root realm.
  • DB dump should have some realm permissions already set. Doesn't need to happen in this PR, rather a reminder.
  • I like the UI a lot. The separator with the note is good. I think everything is clearly communicated.
  • When editing permissions and the current user only gets permission do to that from a parent realm, then trying to save something without yourself explicitly added will cause warning "remove own write access?". So I guess for that check, the flattened roles have to be checked as well.
    • And confirming that, the spinner (which is left aligned for some reason) spins forever, never finishing. But the request went through and the permissions were saved.
  • When a user that only has moderate permissions adds a page, but immediately wants to remove it again, they can't. What do you think about adding "manage" permissions to new pages for the user that creates it?

frontend/src/i18n/locales/en.yaml Outdated Show resolved Hide resolved
frontend/src/i18n/locales/en.yaml Outdated Show resolved Hide resolved
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok reviewed all the frontend changes. Overall I like the generalization. That was definitely the hardest here, to make that work well. I have a bunch of comments, but nothing too major I'd say.

frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Show resolved Hide resolved
frontend/src/ui/Access.tsx Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/routes/manage/Realm/RealmPermissions.tsx Outdated Show resolved Hide resolved
frontend/src/routes/manage/Realm/RealmPermissions.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to test-deployment-pr1097 February 8, 2024 16:19 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1097 February 8, 2024 17:18 Destroyed
@github-actions github-actions bot temporarily deployed to test-deployment-pr1097 February 9, 2024 13:54 Destroyed
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look at your changes after my reviews and that indeed solved basically all my comments. I found a few more things, but these are even more minor than before.

I have not tested it again yet. Will do once most things are resolved.

backend/src/api/model/realm/mod.rs Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
backend/src/api/model/realm/mod.rs Outdated Show resolved Hide resolved
frontend/src/util/permissionLevels.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/routes/manage/Realm/RealmPermissions.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
This adds two fields for different permission levels
and two additions fields to hold inherited permission
levels of parent realms.
`Moderators` enables users to edit content while `admin`
enables everything, including "danger zone" things.

Roles are inherited in an additive manner, meaning
a child realm will inherit the `roles` and `inherited roles`
of their respective parent realm.
@github-actions github-actions bot temporarily deployed to test-deployment-pr1097 February 13, 2024 10:29 Destroyed
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just very few things left! Testing the test deployment soon.

backend/src/api/model/realm/mutations.rs Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/i18n/locales/en.yaml Outdated Show resolved Hide resolved
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested a bunch on the test deployment and everything works very nicely I think!

I only have two translation related things

frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/i18n/locales/de.yaml Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to test-deployment-pr1097 February 13, 2024 14:47 Destroyed
Copy link
Member

@LukasKalbertodt LukasKalbertodt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terribly sorry to yet again click "request changes" but I think this last thing you solved can be solved a bit better. But we are close °_°

frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
frontend/src/ui/Access.tsx Outdated Show resolved Hide resolved
This moves the save and reset button group
into the general ui/Access.tsx file to be reused
in other contexts. It also adds additional
action types that can be passed as a prop.
We previously showed `Administrators` in the user column
when logged in as such, so this didn't need the `no entries` display.
This moved to the groups column but I forgot to adjust the condition.

Also removes an empty `css` prop.
With this, realm editing permissions are initially
restricted to admins. They can add permissions for users
and groups to either `moderate` (i.e. edit content,
add subpages and edit non-critical realm settings) or
`manage` (do everything including deleting realms and
editing their permissions). Permissions are inherited to
children realms, which the ui does not reflect with this
commit. That is added in a following commit.
This shows the permissions that are inherited from
all ancestor realms as immutable entries in the current
realm's acl selectors. Entries that are already being inherited
can still be added to allow "upgrading" permission
levels, i.e. from "moderate" to "manage". However it is worth
noting that adding an entry with "moderate" level while the
inherited permissions already contain that entry with "manage"
permission, that permissions will not be "downgraded".
Basically the permission level of doubled entries will resolve
to the highest level between both entries.
With this, the current user's user role gets included
implicitly in their own user realm. This allows for
easier handling of already existing user realms,
immutability and "inheritance" of that role.
This is only done for subrealms that aren't descendants
of the current user's user realm, since we don't want/need
to add it explicitly in that case.
Since the realm owner is already implicitly included with an
immutable entry in an owner realm's acl, it should be
excluded as an addable option to prevent duplication.
Anonymous users should never be allowed to modify
realm content or settings, so it's safest to just
exclude the option from the realm ACL selectors.
@github-actions github-actions bot temporarily deployed to test-deployment-pr1097 February 13, 2024 17:36 Destroyed
@LukasKalbertodt LukasKalbertodt merged commit e85621a into elan-ev:master Feb 14, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:user User facing changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add granular editing permissions to the realm tree
2 participants