8000 chore: improve rbac and add benchmark tooling by ssncferreira · Pull Request #18584 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: improve rbac and add benchmark tooling #18584

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

Merged
merged 9 commits into from
Jun 27, 2025

Conversation

ssncferreira
Copy link
Contributor
@ssncferreira ssncferreira commented Jun 25, 2025

Description

This PR improves the RBAC package by refactoring the policy, enhancing documentation, and adding utility scripts.

Changes

  • Refactored policy.rego for clarity and readability
  • Updated README with OPA section
  • Added benchmark_authz.sh script for authz performance testing and comparison
  • Added gen_input.go to generate input for opa eval testing

@ssncferreira ssncferreira changed the title chore: rbac improvements and benchmark tooling chore: improve rbac and add benchmark tooling Jun 25, 2025
@ssncferreira ssncferreira force-pushed the ssncferreira/chore-rbac-improvements branch 2 times, most recently from ca7deed to c1fe8e3 Compare June 25, 2025 19:26
@ssncferreira ssncferreira force-pushed the ssncferreira/chore-rbac-improvements branch from c1fe8e3 to 29222a1 Compare June 26, 2025 09:29
8000
@ssncferreira ssncferreira marked this pull request as ready for review June 26, 2025 10:06
@ssncferreira ssncferreira requested review from Emyrk and johnstcn June 26, 2025 10:15
Copy link
Member
@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

Wow! Thanks for all of the work you put into this!

Out of curiousity, I wonder if your changes to the policy had any measurable benchmark difference? I would assume that it remains basically the same, but it could be interesting to see the benchmark results now that we have the tools 😁

@ssncferreira
Copy link
Contributor Author

Wow! Thanks for all of the work you put into this!

Thank you! 🫶 I had some of these things stashed and thought they would be a good addition for future reference.

Out of curiousity, I wonder if your changes to the policy had any measurable benchmark difference? I would assume that it remains basically the same, but it could be interesting to see the benchmark results now that we have the tools 😁

I was a bit worried about breaking something 😅 so I ran the tests yesterday, it was slightly better, but nothing significantly different:

  • RBACAuthorize: -2.23%
  • RBACAuthorizeGroups: +0.18%
  • RBACFilter: -1.29%

benchstat results attached for reference:

Copy link
Member
@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

This is all excellent!

Comment on lines -34 to 40
bool_flip(b) := flipped if {
bool_flip(b) := false if {
b
flipped = false
}

bool_flip(b) := flipped if {
bool_flip(b) := true if {
not b
flipped = true
}
Copy link
Member

Choose a reason for hiding this comment

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

Very nice 👍

Comment on lines -53 to 61
number(set) := c if {
# Return -1 if the set contains any 'false' value (i.e., an explicit deny)
number(set) := -1 if {
false in set
c := -1
}

number(set) := c if {
# Return 0 if the set is empty (no matching permissions)
number(set) := 0 if {
count(set) == 0
}

# Return 1 if the set is non-empty and contains no 'false' values (i.e., only allows)
number(set) := 1 if {
not false in set
set[_]
c := 1
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines 44 to 45
// TODO: support arguments for subject, action and object
func main() {
Copy link
Member

Choose a reason for hiding this comment

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

totally fine to start with this 👍

@ssncferreira ssncferreira merged commit 3cb9b20 into main Jun 27, 2025
35 checks passed
@ssncferreira ssncferreira deleted the ssncferreira/chore-rbac-improvements branch June 27, 2025 11:05
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0