Documentation
¶
Overview ¶
Package pkce implements the in-memory store of per-code authorization state that links a /authorize redirect to its later /oauth/token exchange.
Every code issued by /authorize gets an Entry carrying the nonce and the authorization time, echoed into the id_token. When the client also sent a PKCE code_challenge + code_challenge_method (required by Auth0 and OAuth 2.1 for SPAs and native clients), the Entry carries the challenge too, and the matching code_verifier must be presented on /oauth/token: the verifier must hash back to the stored challenge.
Index ¶
Constants ¶
const DefaultTTL = 10 * time.Minute
DefaultTTL is how long a stored challenge is valid before the matching code becomes unredeemable.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Challenge string
Method Method
ClientID string
Redirect string
// Nonce is the /authorize nonce, echoed into the id_token. May be empty.
Nonce string
// LoginHint is the subject /authorize resolved for the login: the session
// user, the login_hint, or DefaultSubject. It becomes the id_token subject.
LoginHint string
// Audience and Scope are the /authorize audience and scope. When set,
// the code exchange uses them, as Auth0 does. May be empty.
Audience string
Scope string
// AuthTime is the login instant, set by /authorize (a reused session keeps
// its original one). Store.Put stamps the store clock only when it is
// zero. It becomes the id_token auth_time claim.
AuthTime time.Time
// contains filtered or unexported fields
}
Entry is the per-code authorization state stashed at /authorize and consulted at /oauth/token. Challenge and Method are set only when the client used PKCE; Nonce, LoginHint and AuthTime feed the id_token.
type Method ¶
type Method string
Method is the code_challenge_method value the client used at /authorize.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store maps the random code returned by /authorize to its authorization Entry. Entries expire after DefaultTTL. Safe for concurrent use.
func (*Store) Consume ¶
Consume returns the Entry registered against code and removes it. Returns false if the code is unknown or its entry has expired.