Documentation
¶
Overview ¶
Package oidc implements the OpenID Connect Relying Party side of sign-in through an OpenID provider: authorization-code flow with PKCE, issuer pinning (the discovery document's issuer must match the configured issuer), and email_verified respected. Built on github.com/coreos/go-oidc/v3 and golang.org/x/oauth2.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AMRNamesSecondFactor ¶
AMRNamesSecondFactor reports whether an ID token's `amr` names a second factor: the RFC 8176 values for possession, biometric and OTP factors, "mfa" itself, and the provider-specific spellings seen in practice. "pwd" alone is not one. It is the one rule for the directory's sign-in and an organization's OIDC connection.
Types ¶
type Claims ¶
type Claims struct {
Subject string
Email string
EmailVerified bool
Issuer string
// AMR is the token's Authentication Methods References (RFC 8176) as
// the IdP sent them, e.g. ["pwd","mfa"]; nil when absent. ACR is the
// Authentication Context Class Reference, if any. The registry uses
// AMR as evidence that a second factor was used.
AMR []string
ACR string
// Groups is the token's `groups` claim; nil when absent. It grants
// nothing: platform staff is membership of the staff organization.
Groups []string
// PreferredUsername is the `preferred_username` claim: the name the
// person chose at the IdP; "" when absent. It is a seed for a new
// account's handle, never an identifier: OIDC Core §5.7 does not make
// it unique or stable, so nothing is looked up by it.
PreferredUsername string
// AuthTime is the `auth_time` claim: when the person last actually
// authenticated at the IdP, zero when absent. A token minted silently
// against a live IdP session carries the original time, which is how
// the registry tells a fresh sign-in from a replayed session.
AuthTime time.Time
// Raw is every claim of the verified ID token, as JSON decoded it, for
// a reader of claims this type does not name: a deployment's own IdP
// may send claims of its own (an extension reads them through the
// sign-in hook). Never nil for a token that verified.
Raw map[string]any
}
Claims is the subset of ID-token claims the JIT flow consumes.
type Config ¶
type Config struct {
Issuer string `json:"issuer"`
ClientID string `json:"clientId"`
ClientSecret string `json:"clientSecret,omitempty"`
RedirectURL string `json:"redirectUrl,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}
Config is an OpenID provider's relying-party configuration.
type Description ¶
type Description struct {
Issuer string
AuthURL string
TokenURL string
UserInfoURL string
JWKSURL string
}
Description is what discovery established for a connection test: the issuer that answered and its endpoints.
type RP ¶
type RP struct {
// contains filtered or unexported fields
}
RP is a configured Relying Party for one provider.
func New ¶
New builds the RP. coreoidc.NewProvider performs discovery and pins the issuer: it returns an error when the discovery document's issuer differs from cfg.Issuer (issuer pinning). Pass a context carrying a custom *http.Client via coreoidc.ClientContext to reach a private/test IdP.
func (*RP) AuthURL ¶
AuthURL returns the IdP authorization URL for an auth-code + PKCE flow. The caller must persist state, nonce, and verifier (in a short-lived sealed cookie or server-side) and supply them to Exchange.
It asks for no offline access: the registry keeps its own sessions and never uses a refresh token, so asking an IdP to mint one (access_type= offline, a Google convention some IdPs honour) would only create a long-lived credential nobody holds on purpose.
func (*RP) Describe ¶
func (rp *RP) Describe() Description
Describe reports the discovered endpoints. Constructing the RP already performed discovery against the configured issuer, so this is the evidence that the issuer is reachable and self-consistent.