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 policies layer in between roles and permissions #2495

Merged
merged 25 commits into from May 16, 2024

Conversation

jdorn
Copy link
Member

@jdorn jdorn commented May 8, 2024

Features and Changes

Add a "policies" layer in between roles and permissions.

TODO:

  • Default Role -> Policy -> Permission mappings
  • Use this new mapping in the existing permissions code
  • Support for custom organization roles (data model only, no API support or UI yet)

org: OrganizationInterface,
teams: TeamInterface[],
id: string
) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we'll want to add one more check - to prevent deleting a role that is the org's default.

  // Make sure the id isn't the org's default
  if (org.settings?.defaultRole?.role === id) {
    throw new Error(
      "Cannot delete role. This role is set as the organization's default role."
    );
  }

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mknowlton89 mknowlton89 mentioned this pull request May 14, 2024
14 tasks
@mknowlton89
Copy link
Collaborator

I've been testing this alongside the UI PR here and it's working great.

In the PR above I made two small tweaks.

  • I added some logic within the getOrganization to ensure we're passing the org's customRoles to the frontend context so when we call getDefaultRole - the org object we pass in contains the org's customRoles.
  • I also added some logic to the deleteCustomRole endpoint so if the role was being used as the org's default, we block deletion.

@mknowlton89 mknowlton89 marked this pull request as ready for review May 15, 2024 18:43
Copy link

Your preview environment pr-2495-bttf has been deployed.

Preview environment endpoints are available at:

@jdorn
Copy link
Member Author

jdorn commented May 16, 2024

I can't approve since I made the PR, but this looks good to me.

@mknowlton89 mknowlton89 merged commit 4e2e071 into main May 16, 2024
3 checks passed
@mknowlton89 mknowlton89 deleted the permission-policies branch May 16, 2024 13:21
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