AuthZService: improve authz caching#2
Conversation
* remove the use of client side cache for in-proc authz client Co-authored-by: Gabriel MABILLE <gabriel.mabille@grafana.com> * add a permission denial cache, fetch perms if not in either of the caches Co-authored-by: Gabriel MABILLE <gabriel.mabille@grafana.com> * Clean up tests Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> * Cache tests Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> * Add test to list + cache Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> * Add outdated cache test Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> * Re-organize metrics Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> --------- Co-authored-by: Gabriel MABILLE <gabriel.mabille@grafana.com>
WalkthroughThe changes introduce a permission denial cache to the RBAC authorization service, enabling immediate denial responses for cached denials. The code refactors cache handling for permission checks, adds a unified method for retrieving cached permissions, and updates related tests. A new no-op cache implementation and a cache key generator for denials are also added. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Service
participant DenialCache
participant PermCache
participant Store
Client->>Service: Check(namespace, user, action, name, parent)
Service->>DenialCache: Get(denialKey)
alt Denial found
DenialCache-->>Service: Denied
Service-->>Client: Denied (cached)
else Denial not found
Service->>PermCache: Get(permKey)
alt Permission found and allows
PermCache-->>Service: Allowed
Service-->>Client: Allowed (cached)
else Permission not found or denied
Service->>Store: Fetch permissions
Store-->>Service: Permissions
alt Denied
Service->>DenialCache: Set(denialKey, true)
Service-->>Client: Denied
else Allowed
Service-->>Client: Allowed
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🔇 Additional comments (10)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 2 weeks if no further activity occurs. Please feel free to give a status update or ping for review. Thank you for your contributions! |
|
This pull request has been automatically closed because it has not had any further activity in the last 2 weeks. Thank you for your contributions! |
Test 2
Summary by CodeRabbit
New Features
Bug Fixes
Tests