Skip to main content

oidcauthlib

OIDC userinfo scopes (OidcUserInfoManager)

Some providers (e.g. Okta employee access tokens) only carry openid profile email groups in the JWT; the scopes that authorize a caller appear only on the OIDC userinfo response. oidcauthlib.auth.userinfo.oidc_userinfo_manager.OidcUserInfoManager resolves a token's effective scopes from the token's own claims plus the userinfo endpoint, and caches the userinfo-derived scopes in a key-value store.

manager = OidcUserInfoManager(
    auth_config_reader=auth_config_reader,
    well_known_configuration_manager=well_known_configuration_manager,
    store=store,                      # py-key-value-aio store; yours, not shared with other services
    cache_collection="oidc-user-info-cache",
    cache_ttl_seconds=86400,
    fetch_timeout_seconds=30,
    scope_claims=["custom:scope"],    # optional extra claims holding scopes
    group_claims=["groups"],          # optional claims holding group names, used whole as scopes
    scope_remove_prefixes=["fhir/prod/"],
)
scopes = await manager.get_scopes_from_user_info_async(access_token=token)
  • Scope derivation follows fhir-server-ui's jwtParser: the scope claim (plus scp), then scope_claims, then group_claims (each value taken whole). Commas separate like spaces, results are de-duplicated, and scope_remove_prefixes are stripped (first match wins). Nothing beyond scope/scp is read unless configured.
  • Provider is matched to the token's iss: an exact issuer, else a well_known_uri on the same scheme, host and port whose path segments start with the issuer's. Only a token with no iss at all is matched by its client id. A token matching no provider raises ValueError; it is never sent to another provider.
  • Subject check: for a token that has a sub, the userinfo response must carry the same sub (OIDC Core 5.3.2); a missing or different one raises ValueError and nothing is cached.
  • Cache key is oidc-userinfo-scopes:<issuer>:<client_id>:<sub>|v1 with each segment percent-encoded (so values containing : cannot collide, and two providers never share an entry); only the userinfo-derived scopes are stored, never the userinfo response. The token's own scopes are re-derived on every call. A token without sub or without an issuer, or an empty scope list, is not cached. Changes to a user's entitlements are visible after at most cache_ttl_seconds.
  • Failures: the cache never fails a lookup. A write failure is logged and swallowed; a read failure or a malformed entry is logged and treated as a miss, and the refetched scopes overwrite the bad entry. A userinfo HTTP error, a missing provider or a mismatched subject is raised, so each service decides whether to fail closed or degrade.

Metadata

Release files for oidcauthlib 3.0.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oidcauthlib 3.0.28
File Size Uploaded Provenance Actions
oidcauthlib-3.0.28.tar.gz 86.2 kB Without provenance Details for oidcauthlib-3.0.28.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oidcauthlib 3.0.28
File Interpreter ABI Platform Actions
oidcauthlib-3.0.28-py3-none-any.whl Python 3 none any Details for oidcauthlib-3.0.28-py3-none-any.whl

Total release size: 200.2 kB

Release files / oidcauthlib-3.0.28.tar.gz

Download URL oidcauthlib-3.0.28.tar.gz
Size 86.2 kB
Tags Source
SHA-256 checksum
How to use checksums
83f7c5a3637693f3449c1aab7166177a73ef6c702789e6b96851d5ae5c8d9a68
BLAKE2b-256 checksum
How to use checksums
a44b9a48bcb183c2c5cba69b357ddc7bfe438b04016194cfd8fb91a345cbc3fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / oidcauthlib-3.0.28-py3-none-any.whl

Download URL oidcauthlib-3.0.28-py3-none-any.whl
Size 114.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f40b51ee2219b1d6e7513f5cb94844336652973f6fa2ed30be80cb895f6bd7eb
BLAKE2b-256 checksum
How to use checksums
498317a4e27a1886e92a1f070a022013832d844ab95fd326f7e976ea20bcc36c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for oidcauthlib 3.0.28

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.0.28 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page