Add discovery-based GenericOIDCProvider - #14
Open
carlosplanchon wants to merge 1 commit into
Open
Conversation
A single provider for any spec-compliant OpenID Connect IdP (Zitadel,
Keycloak, Authentik, Auth0, Okta, Entra ID, ...). from_discovery() fetches
{issuer}/.well-known/openid-configuration, resolves the authorize/token/
userinfo endpoints, and validates the declared issuer; process_user_info
maps the standard OIDC claims.
Construction is via an async classmethod because discovery is a network
call and the port's sync surface (get_authorization_url) cannot await;
build it once at startup. Deliberately not registered with
OAuthProviderFactory: create_provider builds from name + credentials
alone and cannot carry an issuer, so registering it would only produce a
confusing TypeError. Callers construct it directly instead.
Adds OIDC_DISCOVERY_PATH / OIDC_DEFAULT_SCOPES constants and test_oidc.py
(discovery resolution, PKCE URL, issuer/endpoint validation, claim mapping).
Signed-off-by: Carlos Andrés Planchón Prestes <carlosandresplanchonprestes@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One provider class for any spec-compliant OIDC IdP (Zitadel, Keycloak, Authentik, Auth0, Okta, Entra ID): from_discovery() fetches {issuer}/.well-known/openid-configuration, resolves the authorize/token/userinfo endpoints, and validates that the document's declared issuer matches the requested one (a spec requirement that hand-rolled subclasses tend to skip). process_user_info maps the standard OIDC claims.
Design notes:
Why core rather than a docs example: the issuer validation is the security-sensitive part, and as a copy-paste example every app re-implements it and some will skip it. As core it is written once, tested, and versioned.
Validated live: this class (via a downstream integration) ran a full login against a real self-hosted Zitadel instance, public PKCE client included (pairs with #13 for secretless clients).
Possible follow-up, your call: plumb an issuer field through OAuthCredentials so oauth={...} supports OIDC providers natively; that change would use this class internally and deserves its own design discussion (async init would move to initialize()).