Documentation
¶
Overview ¶
Package oidc wraps coreos/go-oidc to provide OIDC/OAuth2 authentication flows with PKCE. It imports the core auth package for types but never the reverse.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrOIDCDiscovery = errors.New("oidc: provider discovery failed") ErrOIDCExchange = errors.New("oidc: code exchange failed") ErrOIDCTokenInvalid = errors.New("oidc: ID token verification failed") ErrOIDCNonceMismatch = errors.New("oidc: nonce mismatch") ErrOIDCConfigInvalid = errors.New("oidc: invalid configuration") )
Sentinel errors for OIDC operations.
Functions ¶
func GeneratePKCE ¶
GeneratePKCE generates a PKCE code verifier and S256 challenge.
func GenerateState ¶
GenerateState generates a random state string for OIDC flows.
func ResolveUser ¶
ResolveUser maps an OIDC identity to a user by (issuer, sub) only.
func ValidateConfig ¶
ValidateConfig checks that the required fields of a Config are set.
Types ¶
type Claims ¶
type Claims struct {
Subject string `json:"sub"`
Issuer string `json:"iss"`
Email string `json:"email"`
PreferredUsername string `json:"preferred_username"`
Name string `json:"name"`
EmailVerified bool `json:"email_verified"`
}
Claims holds the verified claims extracted from an OIDC ID token.
type Config ¶
type Config struct {
IssuerURL string `json:"issuer_url" yaml:"issuer_url"`
ClientID string `json:"client_id" yaml:"client_id"`
ClientSecret string `json:"-" yaml:"client_secret"`
RedirectURI string `json:"redirect_uri" yaml:"redirect_uri"`
AutoRedirect bool `json:"auto_redirect" yaml:"auto_redirect"`
}
Config holds OIDC provider settings.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider wraps the coreos/go-oidc provider with PKCE support.
func NewProvider ¶
NewProvider creates an OIDC provider from config.
func (*Provider) AuthorizationURL ¶
AuthorizationURL generates the OIDC authorization URL with PKCE and state.