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

Multi-inheritance RBAC (backend) #14816

Merged
merged 46 commits into from
Oct 18, 2024
Merged

Conversation

mike12345567
Copy link
Collaborator

Description

As required for the new RBAC experience roles need a way to reference multiple other roles, meaning that more complex flows of roles can be created.

The main difference within this is the inherits type of a role can be string | string[] - the string format will apply to old roles and built-ins, while the array will be used for new roles to reference a set of roles below them.

With this, there is a high chance of role loops (this was possible previously as you could set two roles to inherit each other, however this would be un-unusable since it doesn't reference any built in (so essentially two public roles). The API has been updated to protect against loops, as well as providing a function in shared-core that can check for loops given a list of roles.

A general pass around prefixing has been performed, making sure that roles always take their external format when returned from the API as well as storing the roles with their complete prefixed format in the DB.

Finally, a few new test cases have been added:

  1. Checks for the accessible endpoint which lists the roles a user has access to, making sure this works with multi-inheritance.
  2. Checks for screen access, making sure that only the screens a user can access based on their routing.roleId are returned.
  3. Checks for role loops in the role save API, i've also updated this test case to Typescript.
  4. Checks for resource permissions, confirming that resources can be accessed based on role multi-inheritance.

…pt - using role test API to make this a bit easier to adjust going forward.
@mike12345567 mike12345567 self-assigned this Oct 17, 2024
@mike12345567 mike12345567 requested a review from a team as a code owner October 17, 2024 11:36
@mike12345567 mike12345567 requested review from adrinr and removed request for a team October 17, 2024 11:36
Copy link

qa-wolf bot commented Oct 17, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

@github-actions github-actions bot added firestorm Data/Infra/Revenue Team size/xl labels Oct 17, 2024
packages/types/src/api/web/role.ts Show resolved Hide resolved
packages/server/src/api/controllers/role.ts Outdated Show resolved Hide resolved
packages/server/src/tests/utilities/TestConfiguration.ts Outdated Show resolved Hide resolved
packages/server/src/tests/utilities/api/role.ts Outdated Show resolved Hide resolved
packages/backend-core/src/security/roles.ts Outdated Show resolved Hide resolved
packages/backend-core/src/security/roles.ts Outdated Show resolved Hide resolved
packages/backend-core/src/security/roles.ts Outdated Show resolved Hide resolved
packages/backend-core/src/security/roles.ts Show resolved Hide resolved
packages/backend-core/src/security/roles.ts Outdated Show resolved Hide resolved
packages/server/src/tests/utilities/TestConfiguration.ts Outdated Show resolved Hide resolved
packages/server/src/tests/utilities/api/role.ts Outdated Show resolved Hide resolved
packages/shared-core/src/helpers/roles.ts Show resolved Hide resolved
@mike12345567 mike12345567 merged commit ddd7b9f into master Oct 18, 2024
11 of 12 checks passed
@mike12345567 mike12345567 deleted the feature/role-multi-inheritance branch October 18, 2024 10:43
@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
firestorm Data/Infra/Revenue Team size/xl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants