Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
ThomasK33 wants to merge1 commit intothomask33/09-26-add_token_scope_support_in_cli
base:thomask33/09-26-add_token_scope_support_in_cli
Choose a base branch
Loading
fromthomask33/09-26-add_detailed_scope_auth_metrics

Conversation

ThomasK33
Copy link
Member

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:

  • NewscopeDecision struct to track detailed authorization outcomes
  • Additional Prometheus metrics to track scope enforcement:
    • coderd_authz_scope_enforcement_total - Counts requests by decision type
    • coderd_authz_scope_enforcement_duration_seconds - Measures latency
    • coderd_authz_scope_allowlist_miss_total - Tracks allow-list misses
  • Updated Rego policy to expose structured decision data
  • Documentation with example PromQL queries for common analysis scenarios

These metrics will help us better understand authorization patterns and identify potential issues with scope configurations.

This was referencedSep 26, 2025
@ThomasK33Graphite App
Copy link
MemberAuthor

ThomasK33 commentedSep 26, 2025
edited
Loading

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.
Learn more

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@ThomasK33ThomasK33 linked an issueSep 26, 2025 that may beclosed by this pull request
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch 2 times, most recently from9d9f50a toa7dd13bCompareSeptember 26, 2025 19:57
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch fromf277494 to51502b5CompareSeptember 28, 2025 10:53
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch froma7dd13b to8b7a31cCompareSeptember 28, 2025 10:53
@ThomasK33ThomasK33 marked this pull request as ready for reviewSeptember 28, 2025 11:08
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch from8b7a31c to7725526CompareSeptember 29, 2025 08:25
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch from51502b5 to9384a37CompareSeptember 29, 2025 08:25
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch from7725526 toe2539b7CompareSeptember 29, 2025 09:43
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch 2 times, most recently from968cd55 to23c8b74CompareSeptember 29, 2025 09:46
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch frome2539b7 to3bf5bf9CompareSeptember 29, 2025 09:46
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch from68d44a5 to364fa3fCompareOctober 1, 2025 13:56
Copy link
Member

@EmyrkEmyrk left a comment
edited
Loading

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

@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsOct 1, 2025
@ThomasK33ThomasK33 reopened thisOct 1, 2025
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch from364fa3f tofa49bdcCompareOctober 2, 2025 07:35
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch 2 times, most recently frombf26332 tod817f31CompareOctober 2, 2025 17:37
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch fromfa49bdc tod7fcc25CompareOctober 2, 2025 17:37
@ThomasK33ThomasK33 marked this pull request as draftOctober 2, 2025 17:37
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch fromd7fcc25 toc4f8c2aCompareOctober 3, 2025 17:59
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch 2 times, most recently fromb076a30 tob020309CompareOctober 6, 2025 09:42
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch 2 times, most recently from6ec4b94 tod9f66caCompareOctober 6, 2025 10:10
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch 2 times, most recently from37cd2d3 to807fafeCompareOctober 6, 2025 10:48
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch 2 times, most recently from11f6a63 to75d7b64CompareOctober 6, 2025 11:24
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch from807fafe to7b72854CompareOctober 6, 2025 11:24
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch from75d7b64 tof244193CompareOctober 6, 2025 11:57
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch from7b72854 to5a425afCompareOctober 6, 2025 11:57
@EmyrkEmyrk self-assigned thisOct 6, 2025
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch from5a425af toe408ecfCompareOctober 6, 2025 21:16
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch fromf244193 to2f3304eCompareOctober 6, 2025 21:16
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch frome408ecf toab2a24fCompareOctober 6, 2025 21:40
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch from2f3304e to1dae22eCompareOctober 6, 2025 21:40
This 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.
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_detailed_scope_auth_metrics branch fromab2a24f to802b588CompareOctober 7, 2025 16:38
@ThomasK33ThomasK33force-pushed thethomask33/09-26-add_token_scope_support_in_cli branch from1dae22e to7eb739cCompareOctober 7, 2025 16:38
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping left review comments

@EmyrkEmyrkEmyrk requested changes

Assignees

@ThomasK33ThomasK33

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Telemetry/metrics: scope enforcement visibility
3 participants
@ThomasK33@dannykopping@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp