Make KeycloakAuthManager cache configurable - #70839
Conversation
b71e2e0 to
27348aa
Compare
1b432a9 to
d777fc9
Compare
|
Sensible thing to make configurable — a hardcoded 30 second auth-decision cache is exactly the sort of thing deployments need to tune. Two things before merge.
cache_ttl_seconds:
description: |
Time (in seconds) to cache auth decisions in ``bulk is_authorized_{resource}`` methods.
type: integer
version_added: 0.9.0
example: ~
default: "30"The import-time read is what forces _CACHE_TTL_SECONDS = conf.getint(CONF_SECTION_NAME, CONF_CACHE_TTL_SECONDS_KEY, fallback=30)Because this is evaluated once at import, the tests need an autouse fixture that reloads the module to change it. Reloading mid-suite is fragile — it rebinds I know @conf_vars({("fab", "cache_ttl"): "1"})
def test_deserialize_user(...):and that has no effect whatsoever — Reading it lazily makes the whole problem go away: def _cache_ttl_seconds() -> int:
return conf.getint(CONF_SECTION_NAME, CONF_CACHE_TTL_SECONDS_KEY, fallback=30)with the two call sites using Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting |
d777fc9 to
88ba445
Compare
88ba445 to
fa7a717
Compare
_CACHE_TTL_SECONDS and _SINGLE_FLIGHT_TIMEOUT_SECONDS configurable
|
updated docs, added lazy init to |
_CACHE_TTL_SECONDS and _SINGLE_FLIGHT_TIMEOUT_SECONDS configurable
Add configuration settings for KeycloakAuthManager
single_flight()cacheAllow deployment managers to configure the cache timeout on
KeycloakAuthManagerbulk authorisation methods.cache_ttl_secondsoption to configure_CACHE_TTL_SECONDSinKeycloakAuthManagercache_timeout_secondsoption to configure_SINGLE_FLIGHT_TIMEOUT_SECONDSinKeycloakAuthManagerWas generative AI tooling used to co-author this PR?