Documentation
¶
Overview ¶
Package oidc implements the OpenID Connect protocol connector for enterprise SSO.
Index ¶
- Variables
- func GenerateNonce() string
- func GeneratePKCE() (verifier, challenge string, err error)
- type Client
- func (c *Client) BuildAuthURL(authEndpoint string, cfg *OIDCConfig, state, nonce, challenge string) string
- func (c *Client) Discover(ctx context.Context, issuer, discoveryURL string) (*DiscoveryDocument, error)
- func (c *Client) ExchangeCode(ctx context.Context, tokenEndpoint string, cfg *OIDCConfig, ...) (*TokenResponse, error)
- func (c *Client) FetchJWKS(ctx context.Context, jwksURI string) (*JWKS, error)
- func (c *Client) VerifyIDToken(rawToken string, jwks *JWKS, cfg *OIDCConfig, expectedNonce string, ...) (*IDTokenClaims, error)
- type DiscoveryDocument
- type HTTPClient
- type IDTokenClaims
- type JWK
- type JWKS
- type OIDCConfig
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDiscoveryFailed = errors.New("sso oidc: provider discovery failed") ErrTokenExchange = errors.New("sso oidc: token exchange failed") ErrInvalidIDToken = errors.New("sso oidc: invalid id_token") ErrSignatureInvalid = errors.New("sso oidc: id_token signature invalid") ErrIssuerMismatch = errors.New("sso oidc: issuer mismatch") ErrAudienceMismatch = errors.New("sso oidc: audience mismatch") ErrNonceMismatch = errors.New("sso oidc: nonce mismatch") ErrTokenExpired = errors.New("sso oidc: token expired") ErrKeyNotFound = errors.New("sso oidc: signing key not found in jwks") )
Functions ¶
func GenerateNonce ¶
func GenerateNonce() string
GenerateNonce creates a secure random nonce string.
func GeneratePKCE ¶
GeneratePKCE creates an RFC 7636 code verifier and S256 challenge.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(httpClient HTTPClient) *Client
func (*Client) BuildAuthURL ¶
func (c *Client) BuildAuthURL(authEndpoint string, cfg *OIDCConfig, state, nonce, challenge string) string
BuildAuthURL constructs the provider authorization URL with PKCE and Nonce.
func (*Client) Discover ¶
func (c *Client) Discover(ctx context.Context, issuer, discoveryURL string) (*DiscoveryDocument, error)
Discover fetches the OpenID Connect discovery document.
func (*Client) ExchangeCode ¶
func (c *Client) ExchangeCode(ctx context.Context, tokenEndpoint string, cfg *OIDCConfig, code, verifier, redirectURI string) (*TokenResponse, error)
ExchangeCode exchanges an authorization code for tokens.
func (*Client) VerifyIDToken ¶
func (c *Client) VerifyIDToken(rawToken string, jwks *JWKS, cfg *OIDCConfig, expectedNonce string, now time.Time) (*IDTokenClaims, error)
VerifyIDToken strictly verifies signature, issuer, audience, expiration, and nonce.
type DiscoveryDocument ¶
type HTTPClient ¶
HTTPClient abstracts outbound HTTP request execution.
type IDTokenClaims ¶
type OIDCConfig ¶
type OIDCConfig struct {
Issuer string `json:"issuer"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
RedirectURI string `json:"redirect_uri"`
Scopes []string `json:"scopes"`
DiscoveryURL string `json:"discovery_url,omitempty"`
SkipIssuerCheck bool `json:"skip_issuer_check,omitempty"`
}
OIDCConfig contains OpenID Connect specific parameters.
Click to show internal directories.
Click to hide internal directories.