angel3_oidc_server 10.0.1
angel3_oidc_server: ^10.0.1 copied to clipboard
OpenID Connect for an Angel3 OAuth 2.0 server of angel3_auth_server, of ID tokens, JWKS, discovery and UserInfo.
Change Log #
10.0.1 #
Fixes in 10.0.1 #
- Docs: The README is rewritten in plain English, with subsections for signing keys, ID tokens, signing in and logout, and the client registration metadata as a table of rules and defaults
10.0.0 #
New in 10.0.0 #
- OpenID Provider:
OpenIdServerextends theAuthorizationServerofangel3_auth_serverinto an OpenID Provider (OpenID Connect Core 1.0). You implementsubjectOf,clientIdOfandclaimsOfon top of the usualAuthorizationServermethods. ItssigningKeyscannot be changed after the server is built - Signing keys:
OpenIdSigningKeyis anRS256orES256key with a key id. Generate one, store itstoJson()as a secret, and load it withfromJwk. RS256 signatures are blinded, and each one is checked before it is used. A key is refused when it loads if its private part does not match its public part, or if it is an RSA key under 2048 bits. A server needs at least one RS256 key - ID tokens:
issueIdTokensigns an ID token withiss,sub,aud,expandiat, plus thenonce,auth_timeandat_hashof the access token when given.IdTokenResponsereturns it with the access token. Tokens are valid foridTokenLifetime, 10 minutes by default- Pass the code's
OpenIdRequestand the client'sOpenIdClientMetadata, andissueIdTokentakes thenoncefrom them, the signing algorithm (afteridTokenAlgorithmOf, defaulting to RS256), and whetherauth_timeis required. It is required for amax_age, or for a client that registeredrequire_auth_timeordefault_max_age; without anauthTime,issueIdTokenthrows - Extra
claimscannot override the token's own claims. Access tokens must be ASCII, and a request whose scopes leave outopenidcannot get an ID token
- Pass the code's
- Authorization requests: Every authorization request that asks for the
openidscope, or for no scope, has its OpenID Connect parameters checked throughcheckAuthorizationRequest. A malformedprompt, or amax_agethat is not a whole number of seconds, is aninvalid_requestredirected to the client.requestAuthorizationCodereceives the parsedOpenIdRequest, with the request'snonce,promptandmax_age - Signing in:
OpenIdRequest.interactionssays what to do with the user before a code is issued: sign them in (they are not signed in, their sign-in is older thanmax_ageor the client'sdefault_max_age, orprompt=login), let them pick an account, or ask for consent. Withprompt=noneit throwslogin_required,account_selection_requiredorconsent_requiredinstead, which are redirected to the client- Ask it once, when the request arrives. If the user has to sign in or consent, keep the request in the server-side session under a random, single-use id, and issue the code yourself with
completeAuthorizationCodeonce they have; the README shows how. Sending them back to the authorization endpoint would ask them again max_agemust be whole seconds, and is capped atOpenIdRequest.maxMaxAge(about 68 years). A request with no scope has its parameters checked too, since the app may grantopenidby default, and can then get an ID token. So decide whether to issue an ID token from the scopes granted, not fromOpenIdRequest.isOpenId, which is false for such a request
- Ask it once, when the request arrives. If the user has to sign in or consent, keep the request in the server-side session under a random, single-use id, and issue the code yourself with
- JWKS:
jwksEndpointpublishes the public keys of allsigningKeys, so keys can be rotated - UserInfo:
userInfoEndpointreturns thesuband the user's claims allowed by the access token's scopes, usingstandardScopeClaimsor your ownscopeClaims. It requires an access token with theopenidscope - Logout:
endSessionEndpointsigns a user out at a client's request (OpenID Connect RP-Initiated Logout 1.0). Anid_token_hintmust be an ID token from this provider, expired or not: signed with its keys, from its issuer, with asuband anaud, and not a logout token. It only redirects to apost_logout_redirect_urifrompostLogoutRedirectUrisOffor the client, passing back thestate. You implementendSessionto sign the user out; by default it refuses - Client registration:
checkClientMetadatachecks and fills in the client metadata of OpenID Connect Dynamic Client Registration 1.0, and refuses features the server does not support.post_logout_redirect_urisfollow the same rules asredirect_uris, throughredirectUriProblemofangel3_auth_server. Adefault_max_ageis capped atOpenIdRequest.maxMaxAge, likemax_age.OpenIdClientMetadatareads the stored metadata back. Clients may register theopenidscope even whenServerMetadata.scopesdoes not list it - Configuration:
openIdConfigurationOfandopenIdConfigurationEndpointserve the OpenID Provider configuration (OpenID Connect Discovery 1.0) atopenIdConfigurationPath. It includes thejwks_uri,userinfo_endpoint,end_session_endpointandprompt_values_supported, and says thatclaimsrequests and request objects are not supported. The RFC 8414 metadata lists theopenidscope too