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

Introduce hasPermission mixin for checking rbac in frontend #1004

Merged
merged 2 commits into from Sep 22, 2022

Conversation

knolleary
Copy link
Member

Prereq of #657

This PR changes how the frontend verifies if a user is allowed to access something.

It refactors the permissions table we use to secure the API so that it can also be used in the frontend via a new mixin called hasPermission.

hasPermission(scope) will return true/false depending on whether the current user has the necessarily team role for the given scope.

This is a much more declarative approach than testing specific role levels in each view. It also means we have a single source of truth for the rbac table.


You may note the mixin is called hasPermission, whilst its backend equivalent is called needsPermission. This reflects the differences in behaviour between the two.

  • hasPermission returns a boolean
  • needsPermission is a route preHandler that will reject an http request if the permission check fails

@hardillb hardillb merged commit d49255b into main Sep 22, 2022
@Pezmc Pezmc deleted the add-hasperms branch October 19, 2022 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants