4.10.0 — 2026-05-18¶
← 4.10.1 | 4.9.3 → | ↑ 4.x series
Added¶
Adapters - Keycloak¶
- Batch UMA Permission Checks - Added
check_permissions_batchtoKeycloakPortandAsyncKeycloakPort(and their adapter implementations) for evaluating multiple(resource, scope)pairs in a single UMA call.- Returns a
frozenset[tuple[str, str]]containing only the granted pairs from the requested set. - Sync implementation wraps
KeycloakOpenID.uma_permissions; async implementation wrapsa_uma_permissions. - Cached with
ttl_cache_decorator(ttl_seconds=30, maxsize=200)(sync) andalru_cache(ttl=30, maxsize=200)( async) to avoid redundant Keycloak round-trips. - Existing
check_permissionsnow documentscheck_permissions_batchas the preferred entry point when multiple pairs must be checked per request.
- Returns a
Changed¶
Adapters - Keycloak¶
get_userinfoTrusts UserInfo Endpoint - Removed the localvalidate_tokenprecheck from both sync and asyncget_userinfoimplementations.- The Keycloak UserInfo endpoint already validates the token server-side, so the extra local validation was redundant and an unnecessary network round-trip.
- Dropped the now-unused
InvalidTokenErrorimport fromarchipy/adapters/keycloak/adapters.py. - Docstrings updated to call out that UserInfo handles validation.
Helpers - Keycloak Utils¶
- Shared Adapter Instances -
KeycloakUtils._get_keycloak_adapterand_get_async_keycloak_adapternow delegate to process-wide@cached factories (_shared_sync_adapter,_shared_async_adapter) instead of constructing a new adapter per decorator invocation. - Authorization Pipeline Consolidation - Extracted the gRPC auth-decorator authorization flow into reusable helpers
and used the new batch permission API throughout.
- Added
_authorize_sync/_authorize_asynchelpers that validate the token, fetch token info, retrieve UserInfo, perform optional resource-ownership checks, enforce role requirements, and run batch permission checks. - Added
_extract_roles,_check_resource_access, and_build_auth_contexthelpers to centralize role aggregation (realm + client), ownership/admin checks, andAuthContextconstruction. - Role enforcement now uses local
setoperations against UserInfo claims (issuperset/isdisjoint) rather than issuing separatehas_all_roles/has_any_of_rolescalls. - Permission enforcement uses
check_permissions_batchand surfaces missing pairs via themissing_permissionsfield inPermissionDeniedError.additional_data. BaseErrorinstances raised inside async wrappers are re-raised after the optional gRPC abort, preventing them from being wrapped intoInternalError.
- Added
Helpers - Decorators¶
- Sharper Tracing Decorator Generics -
capture_transaction,capture_span,async_capture_transaction, andasync_capture_spannow bind their genericFto local_Function/_AsyncFunctionProtocolclasses that require a__name__attribute, replacing the looserCallable[..., Any]bound and giving callers better type narrowing on decorated functions.