Documentation
¶
Overview ¶
Package idp is a thin generic OIDC RP — authlet's AS uses it to forward user authentication to an upstream issuer (Google, another authlet, etc).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoUser = errors.New("idp: no matching user")
ErrNoUser indicates that the upstream claims did not resolve to a known internal user.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct {
Issuer string `json:"iss"`
Subject string `json:"sub"`
Email string `json:"email"`
EmailVerified bool `json:"email_verified"`
Name string `json:"name"`
Picture string `json:"picture"`
Raw map[string]any
}
Claims is the subset of OIDC ID token claims authlet cares about.
type OIDCProvider ¶
type OIDCProvider struct {
// contains filtered or unexported fields
}
OIDCProvider is a configured upstream OIDC issuer. It pairs a verifier for inbound ID tokens with an oauth2 config used to drive the authorization code flow.
func NewForTest ¶
func NewForTest(issuerURL string) *OIDCProvider
NewForTest is a test-only helper that constructs an OIDCProvider with stub-but-non-nil internals so it satisfies Configured() without doing network discovery. Use from external test packages only.
func NewOIDC ¶
func NewOIDC(ctx context.Context, issuerURL, clientID, clientSecret, redirectURL string, scopes []string) (*OIDCProvider, error)
NewOIDC discovers the issuer's metadata and returns a configured provider.
func (*OIDCProvider) AuthURL ¶
func (p *OIDCProvider) AuthURL(state string) string
AuthURL returns the upstream authorize URL for the given state.
func (*OIDCProvider) Configured ¶
func (p *OIDCProvider) Configured() bool
Configured reports whether the provider was constructed via NewOIDC. A zero-valued *OIDCProvider is not configured and will panic if used, so callers (notably as.Config.validate) check this rather than just a nil pointer.
func (*OIDCProvider) Exchange ¶
Exchange exchanges an upstream authorization code for an ID token and returns the parsed claims.
func (*OIDCProvider) Issuer ¶
func (p *OIDCProvider) Issuer() string
Issuer returns the upstream issuer URL this provider was configured with.
type UserResolver ¶
UserResolver maps upstream OIDC claims to an internal user ID. Apps implement this against their own user table.
type UserResolverFunc ¶
UserResolverFunc is a function adapter that lets a plain function satisfy the UserResolver interface.