- Notifications
You must be signed in to change notification settings - Fork1k
feat: add scope enforcement metrics to RBAC authorizer#19991
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:thomask33/09-26-add_token_scope_support_in_cli
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ThomasK33 commentedSep 26, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stackon Graphite.
This stack of pull requests is managed byGraphite. Learn more aboutstacking. |
9d9f50a
toa7dd13b
Comparef277494
to51502b5
Comparea7dd13b
to8b7a31c
Compare8b7a31c
to7725526
Compare51502b5
to9384a37
Compare7725526
toe2539b7
Compare968cd55
to23c8b74
Comparee2539b7
to3bf5bf9
Compare68d44a5
to364fa3f
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I am hesitant to add a second rego query into ourauthorize
.
Authz is used so much, we really need to be careful.
Before
BenchmarkRBACAuthorizeGroups/NoRolesGroupACL-16 28518 40845 ns/opBenchmarkRBACAuthorizeGroups/AdminGroupACL-16 6112 195361 ns/opBenchmarkRBACAuthorizeGroups/OrgAdminGroupACL-16 5356 234469 ns/opBenchmarkRBACAuthorizeGroups/OrgMemberGroupACL-16 10000 100159 ns/opBenchmarkRBACAuthorizeGroups/ManyRolesGroupACL-16 2281 499800 ns/opBenchmarkRBACAuthorizeGroups/ManyRolesCachedSubjectGroupACL-16 3020 371300 ns/opBenchmarkRBACAuthorizeGroups/AdminWithScopeGroupACL-16 5926 195747 ns/opBenchmarkRBACAuthorizeGroups/StaticRolesGroupACL-16 6212 196050 ns/opBenchmarkRBACAuthorizeGroups/StaticRolesWithCacheGroupACL-16 6204 192148 ns/op
After
BenchmarkRBACAuthorizeGroups/NoRolesGroupACL-16 9763 110225 ns/opBenchmarkRBACAuthorizeGroups/AdminGroupACL-16 2893 424697 ns/opBenchmarkRBACAuthorizeGroups/OrgAdminGroupACL-16 2864 431330 ns/opBenchmarkRBACAuthorizeGroups/OrgMemberGroupACL-16 5791 208606 ns/opBenchmarkRBACAuthorizeGroups/ManyRolesGroupACL-16 1299 925884 ns/opBenchmarkRBACAuthorizeGroups/ManyRolesCachedSubjectGroupACL-16 1452 791876 ns/opBenchmarkRBACAuthorizeGroups/AdminWithScopeGroupACL-16 2835 410499 ns/opBenchmarkRBACAuthorizeGroups/StaticRolesGroupACL-16 2750 426986 ns/opBenchmarkRBACAuthorizeGroups/StaticRolesWithCacheGroupACL-16 2754 423130 ns/op
Benchmarks fixed here:#20097
364fa3f
tofa49bdc
Comparebf26332
tod817f31
Comparefa49bdc
tod7fcc25
Compared7fcc25
toc4f8c2a
Compareb076a30
tob020309
Compare6ec4b94
tod9f66ca
Compare37cd2d3
to807fafe
Compare11f6a63
to75d7b64
Compare807fafe
to7b72854
Compare75d7b64
tof244193
Compare7b72854
to5a425af
Compare5a425af
toe408ecf
Comparef244193
to2f3304e
Comparee408ecf
toab2a24f
Compare2f3304e
to1dae22e
CompareThis change introduces new Prometheus metrics to provide detailed insightsinto authorization decisions, particularly for API key scopes. Thesemetrics help administrators understand why a request was allowed ordenied by breaking down the outcome.The new metrics are:- `coderd_authz_scope_enforcement_total`: Classifies each authorization request by its outcome (e.g., scope_allow, scope_deny, allow_list_deny) and resource type.- `coderd_authz_scope_enforcement_duration_seconds`: Measures the latency of scope enforcement decisions.- `coderd_authz_scope_allowlist_miss_total`: Tracks requests denied specifically due to a resource not being in a scope's allow-list.To implement this efficiently, a new `scope_metrics` rule was added tothe Rego policy. This allows the authorizer to gather detailed outcomeinformation in a single evaluation, avoiding redundant computations.The documentation for Prometheus has been updated to include details andexample queries for the new metrics.
ab2a24f
to802b588
Compare1dae22e
to7eb739c
Compare
Add scope enforcement metrics to RBAC authorizer
This PR adds detailed metrics to track scope enforcement decisions in the RBAC authorizer. It helps us understand why requests are allowed or denied, particularly focusing on scope-based decisions versus role or ACL-based decisions.
The changes include:
scopeDecision
struct to track detailed authorization outcomescoderd_authz_scope_enforcement_total
- Counts requests by decision typecoderd_authz_scope_enforcement_duration_seconds
- Measures latencycoderd_authz_scope_allowlist_miss_total
- Tracks allow-list missesThese metrics will help us better understand authorization patterns and identify potential issues with scope configurations.