Skip to content

Conversation

@akshayutture-augment
Copy link

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Test 2


Replicated from ai-code-review-evaluation/grafana-cursor#2


Note

Adds a cached-permission fast path and explicit denial cache to RBAC checks/lists, updates metrics, and refactors RBAC client creation to use authzlib with configurable cache.

  • AuthZ RBAC service:
    • Caching:
      • Add permDenialCache with key userPermDenialCacheKey(...) to short-circuit known denials in Check.
      • Introduce getCachedIdentityPermissions and use it in Check and List to return on cache hit before DB calls.
      • Populate denial cache on non-allowed checks; maintain existing permCache/idCache behavior.
      • Update metrics.permissionCacheUsage and request counters to reflect cache hits/misses.
    • Refactors:
      • Remove pre-check cache lookups from getUserPermissions/getAnonymousPermissions (handled centrally via getCachedIdentityPermissions).
  • Client setup (pkg/services/authz/rbac.go):
    • Replace newRBACClient with direct authzlib.NewClient usage.
    • In in-proc mode, use NoopCache; remote client uses local cache with TTLs; tracer wired via option.
  • Tests:
    • Add coverage for cached allow, cache miss fallback, outdated cache fallback, and explicit deny cache in Check.
    • Add cache-based listing test; adjust existing tests to new caching flow.

Written by Cursor Bugbot for commit d9dc93c. Configure here.

* remove the use of client side cache for in-proc authz client

Co-authored-by: Gabriel MABILLE <[email protected]>

* add a permission denial cache, fetch perms if not in either of the caches

Co-authored-by: Gabriel MABILLE <[email protected]>

* Clean up tests

Co-authored-by: Ieva <[email protected]>

* Cache tests

Co-authored-by: Ieva <[email protected]>

* Add test to list + cache

Co-authored-by: Ieva <[email protected]>

* Add outdated cache test

Co-authored-by: Ieva <[email protected]>

* Re-organize metrics

Co-authored-by: Ieva <[email protected]>

---------

Co-authored-by: Gabriel MABILLE <[email protected]>
@akshayutture-augment
Copy link
Author

cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!


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.

3 participants