AuthZService: improve authz caching#11
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>
Codoki PR ReviewSummary: Harden denial cache keys, prevent collisions Issues (Critical & High only)
Showing top 1 issues. Critical: 0, High: 1. See inline suggestions for more. Key Feedback (click to expand)
Confidence: 3/5 — Needs work before merge (1 high · status: Requires changes) Sequence DiagramsequenceDiagram
participant Caller
participant Service
Caller->>Service: Check()
opt build permDenialKey
alt permDenialCache hit
Service-->>Caller: Allowed=false
else cache miss
Service->>Service: getCachedIdentityPermissions()
alt cached perms found
Service->>Service: checkPermission()
alt allowed
Service-->>Caller: Allowed=true
else not allowed
Service->>Service: getIdentityPermissions()
Service->>Service: checkPermission()
alt not allowed
Service->>Service: permDenialCache.Set()
Service-->>Caller: Allowed=false
else allowed
Service-->>Caller: Allowed=true
end
end
else not found
Service->>Service: getIdentityPermissions()
Service->>Service: checkPermission()
alt not allowed
Service->>Service: permDenialCache.Set()
Service-->>Caller: Allowed=false
else allowed
Service-->>Caller: Allowed=true
end
end
end
end
React with 👍 or 👎 if you found this review useful. |
| } | ||
|
|
||
| func userPermDenialCacheKey(namespace, userUID, action, name, parent string) string { | ||
| return namespace + ".perm_" + userUID + "_" + action + "_" + name + "_" + parent |
There was a problem hiding this comment.
| return namespace + ".perm_" + userUID + "_" + action + "_" + name + "_" + parent | |
| return namespace + ".perm_" + userUID + "_" + action + "\x1F" + name + "\x1F" + parent |
Mirrors ai-code-review-evaluation#2 for like-for-like benchmarking.
cache-optimization-baselineauthz-service-improve-caching-prOriginal PR excerpt: