Documentation
¶
Overview ¶
Package oauth provides OAuth 2.0 and OIDC authentication functionality.
Package oauth provides OAuth 2.0 and OIDC authentication functionality.
Package oauth provides OAuth 2.0 and OIDC authentication functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ClientID is the OAuth client ID
ClientID string
// ClientSecret is the OAuth client secret (optional for PKCE flow)
ClientSecret string
// RedirectURL is the redirect URL for the OAuth flow
RedirectURL string
// AuthURL is the authorization endpoint URL
AuthURL string
// TokenURL is the token endpoint URL
TokenURL string
// Scopes are the OAuth scopes to request
Scopes []string
// UsePKCE enables PKCE (Proof Key for Code Exchange) for enhanced security
UsePKCE bool
// CallbackPort is the port for the OAuth callback server (optional, 0 means auto-select)
CallbackPort int
// IntrospectionEndpoint is the optional introspection endpoint for validating tokens
IntrospectionEndpoint string
// OAuthParams are additional parameters to pass to the authorization URL
OAuthParams map[string]string
}
Config contains configuration for OAuth authentication
func CreateOAuthConfigFromOIDC ¶
func CreateOAuthConfigFromOIDC( ctx context.Context, issuer, clientID, clientSecret string, scopes []string, usePKCE bool, callbackPort int, ) (*Config, error)
CreateOAuthConfigFromOIDC creates an OAuth config from OIDC discovery
func CreateOAuthConfigManual ¶ added in v0.2.4
func CreateOAuthConfigManual( clientID, clientSecret string, authURL, tokenURL string, scopes []string, usePKCE bool, callbackPort int, oauthParams map[string]string, ) (*Config, error)
CreateOAuthConfigManual creates an OAuth config with manually provided endpoints
type Flow ¶
type Flow struct {
// contains filtered or unexported fields
}
Flow handles the OAuth authentication flow
func (*Flow) TokenSource ¶ added in v0.0.48
func (f *Flow) TokenSource() oauth2.TokenSource
TokenSource returns the OAuth2 token source for refreshing tokens
type OIDCDiscoveryDocument ¶
type OIDCDiscoveryDocument struct {
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
IntrospectionEndpoint string `json:"introspection_endpoint,omitempty"`
TokenEndpoint string `json:"token_endpoint"`
UserinfoEndpoint string `json:"userinfo_endpoint"`
JWKSURI string `json:"jwks_uri"`
CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported,omitempty"`
}
OIDCDiscoveryDocument represents the OIDC discovery document structure This is a simplified wrapper around the Zitadel OIDC discovery
func DiscoverOIDCEndpoints ¶
func DiscoverOIDCEndpoints(ctx context.Context, issuer string) (*OIDCDiscoveryDocument, error)
DiscoverOIDCEndpoints discovers OAuth endpoints from an OIDC issuer