{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package oidc\n\n## Functions\n\n```go\nfunc GenerateState() (string, error)\n```\nGenerateState produces a cryptographically random state parameter.\n\n## Types\n\n```go\ntype Claims struct {\n\tSubject       string   `json:\"sub\"`\n\tEmail         string   `json:\"email\"`\n\tEmailVerified bool     `json:\"email_verified\"`\n\tName          string   `json:\"name\"`\n\tGroups        []string `json:\"groups,omitempty\"`\n\tIssuer        string   `json:\"iss\"`\n\tAudience      string   `json:\"aud\"`\n\tExpiresAt     int64    `json:\"exp\"`\n\tIssuedAt      int64    `json:\"iat\"`\n}\n```\nClaims represents the standard claims extracted from an ID token.\n\n```go\nfunc ParseIDTokenUnverified(idToken string) (*Claims, error)\n```\nParseIDTokenUnverified extracts claims from an ID token without cryptographic verification. Use this only when you have already validated the token via the token endpoint response.\n\n```go\ntype Config struct {\n\tIssuer       string   `json:\"issuer\" yaml:\"issuer\"`\n\tClientID     string   `json:\"client_id\" yaml:\"client_id\"`\n\tClientSecret string   `json:\"client_secret\" yaml:\"client_secret\"` //nolint:gosec // G117: OIDC config field\n\tRedirectURI  string   `json:\"redirect_uri\" yaml:\"redirect_uri\"`\n\tScopes       []string `json:\"scopes\" yaml:\"scopes\"`\n}\n```\nConfig holds OIDC provider configuration.\n\n```go\nfunc (c Config) Validate() error\n```\nValidate checks that required configuration fields are set.\n\n```go\ntype DiscoveryDocument struct {\n\tIssuer                string   `json:\"issuer\"`\n\tAuthorizationEndpoint string   `json:\"authorization_endpoint\"`\n\tTokenEndpoint         string   `json:\"token_endpoint\"`\n\tUserInfoEndpoint      string   `json:\"userinfo_endpoint\"`\n\tJWKSURI               string   `json:\"jwks_uri\"`\n\tScopesSupported       []string `json:\"scopes_supported\"`\n}\n```\nDiscoveryDocument represents the OpenID Connect discovery response.\n\n```go\ntype HTTPClient interface {\n\tDo(req *http.Request) (*http.Response, error)\n}\n```\nHTTPClient is the interface for making HTTP requests (allows testing).\n\n```go\ntype Provider struct {\n\t// contains filtered or unexported fields\n}\n```\nProvider handles OIDC authentication flows.\n\n```go\nfunc NewProvider(cfg Config, client HTTPClient) (*Provider, error)\n```\nNewProvider creates a new OIDC provider with the given configuration.\n\n```go\nfunc (p *Provider) AuthorizationURL(ctx context.Context, state string) (string, error)\n```\nAuthorizationURL builds the URL to redirect users for authentication.\n\n```go\nfunc (p *Provider) CallbackHandler(onSuccess func(w http.ResponseWriter, r *http.Request, claims *Claims, tokens *TokenResponse)) http.HandlerFunc\n```\nCallbackHandler returns an HTTP handler that processes the OIDC authorization code callback. On success it calls onSuccess with the extracted claims.\n\n```go\nfunc (p *Provider) Config() Config\n```\nConfig returns the provider's configuration.\n\n```go\nfunc (p *Provider) Discover(ctx context.Context) (*DiscoveryDocument, error)\n```\nDiscover fetches the OIDC discovery document from the issuer.\n\n```go\nfunc (p *Provider) ExchangeCode(ctx context.Context, code string) (*TokenResponse, error)\n```\nExchangeCode exchanges an authorization code for tokens.\n\n```go\ntype TokenResponse struct {\n\tAccessToken  string `json:\"access_token\"` //nolint:gosec // G117: OIDC token response field\n\tTokenType    string `json:\"token_type\"`\n\tExpiresIn    int    `json:\"expires_in\"`\n\tRefreshToken string `json:\"refresh_token,omitempty\"` //nolint:gosec // G117: OIDC token response field\n\tIDToken      string `json:\"id_token,omitempty\"`\n}\n```\nTokenResponse represents the response from the token endpoint.\n\n","path":"github.com/GoCodeAlone/workflow/auth/oidc","name":"oidc","synopsis":"","isRedistributable":true}
