Documentation
¶
Overview ¶
Package oidcapp is a small web app that signs users in with an OpenID Connect provider, through the authorization code flow with PKCE, and reads their profile from the provider's userinfo endpoint. It is the app under test of the OpenID Connect end-to-end tests: it knows nothing about vlatte, only the issuer it is given, and finds everything else through the provider's discovery document. It uses the standard library alone.
Index ¶
Constants ¶
const ( // LoginCookie holds the state, the nonce and the PKCE code verifier of a sign-in, from /login to /callback. LoginCookie = "oidc_login" SessionCookie = "session" )
Cookies the app sets in the browser.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the web app. Its cookies are Secure: serve it over HTTPS. Its routes:
- GET /login sends the browser to the provider to sign in, with a state, a nonce and a PKCE code challenge (S256).
- GET /callback is where the provider sends it back. It checks the state, exchanges the code and the code verifier for tokens, validates the ID token, starts a session and sends the browser to /me.
- GET /me answers, as JSON, the sub, email and name of the ID token.
- GET /profile answers, as JSON, the sub, name and picture the userinfo endpoint answers for the access token.
The ID token must be signed with RS256 by a key of the provider's JWKS, which the app fetches when it first needs it and again when a token names a key it doesn't know. Its issuer, audience, expiry and nonce must be the expected ones, and its email verified. Without a session, /me and /profile answer 401. When the provider refuses the access token, the app ends the session and answers 401.
type Config ¶
type Config struct {
// IssuerURL is the issuer of the provider: its discovery document is at IssuerURL/.well-known/openid-configuration.
IssuerURL string
// ClientID and ClientSecret are the credentials of the app, which it sends with client_secret_post.
ClientID string
ClientSecret string
// RedirectURL is where the provider sends the browser back to: the /callback route of this app.
RedirectURL string
// Scope is what the app asks the user to grant, such as "openid email profile".
Scope string
}
Config is where the provider is and who the app is to it.