oidc

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OIDCDiscoveryPath = "/.well-known/openid-configuration"
	OAuthASMetaPath   = "/.well-known/oauth-authorization-server"
	OAuthPRMetaPath   = "/.well-known/oauth-protected-resource"
	JWKSPath          = "/.well-known/jwks.json"
)
View Source
const (
	ResponseTypeCode = "code"

	GrantAuthorizationCode = "authorization_code"
	GrantRefreshToken      = "refresh_token"

	PKCEMethodS256 = "S256"

	TokenTypeBearer = "Bearer"

	TokenAuthNone  = "none"
	TokenAuthBasic = "client_secret_basic"
	TokenAuthPost  = "client_secret_post"
)
View Source
const (
	OAuthErrInvalidRequest       = "invalid_request"
	OAuthErrInvalidClient        = "invalid_client"
	OAuthErrInvalidGrant         = "invalid_grant"
	OAuthErrUnauthorizedClient   = "unauthorized_client"
	OAuthErrUnsupportedGrantType = "unsupported_grant_type"
	OAuthErrInvalidScope         = "invalid_scope"
	OAuthErrServerError          = "server_error"

	OAuthErrUnsupportedResponseType = "unsupported_response_type"
	OAuthErrAccessDenied            = "access_denied"
	OAuthErrTemporarilyUnavailable  = "temporarily_unavailable"
)
View Source
const SigningKeyID = "1"

Variables

View Source
var (
	SupportedResponseTypes = []string{ResponseTypeCode}
	SupportedGrantTypes    = []string{GrantAuthorizationCode, GrantRefreshToken}
	SupportedPKCEMethods   = []string{PKCEMethodS256}

	SupportedTokenEndpointAuthMethods = []string{TokenAuthBasic, TokenAuthPost}

	SupportedRevocationEndpointAuthMethods = []string{TokenAuthBasic}

	SupportedScopes = []string{scopeOpenID, scopeEmail, scopeProfile, scopePhone}

	SupportedClaims = []string{"sub", "email", "phone_number", "name", "locale", "picture"}
)

Functions

func AppendQuery

func AppendQuery(uri string, params url.Values) string

func IsSupportedGrant

func IsSupportedGrant(grant string) bool

func IsValidPKCEChallenge

func IsValidPKCEChallenge(codeChallenge, method string) bool

func OAuthErrorRedirect

func OAuthErrorRedirect(redirectURI, errCode, state string) events.APIGatewayProxyResponse

func OAuthErrorResp

func OAuthErrorResp(status int, code, description string) events.APIGatewayProxyResponse

func ResetDiscoveryCachesForTest

func ResetDiscoveryCachesForTest()

func ValidateResponseType

func ValidateResponseType(responseType string) string

Types

type AuthServerMetadata

type AuthServerMetadata struct {
	Issuer                                 string   `json:"issuer"`
	AuthorizationEndpoint                  string   `json:"authorization_endpoint"`
	TokenEndpoint                          string   `json:"token_endpoint"`
	RevocationEndpoint                     string   `json:"revocation_endpoint"`
	JWKSURI                                string   `json:"jwks_uri"`
	ResponseTypesSupported                 []string `json:"response_types_supported"`
	GrantTypesSupported                    []string `json:"grant_types_supported"`
	ScopesSupported                        []string `json:"scopes_supported"`
	CodeChallengeMethodsSupported          []string `json:"code_challenge_methods_supported"`
	TokenEndpointAuthMethodsSupported      []string `json:"token_endpoint_auth_methods_supported"`
	RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported"`
}

func BuildAuthServerMetadata

func BuildAuthServerMetadata(issuer, apiBase string) AuthServerMetadata

type DiscoveredEndpoints

type DiscoveredEndpoints struct {
	AuthorizeURL string `json:"authorization_endpoint"`
	TokenURL     string `json:"token_endpoint"`
	UserinfoURL  string `json:"userinfo_endpoint"`
	JWKSURI      string `json:"jwks_uri"`
}

func ResolveIssuerEndpoints

func ResolveIssuerEndpoints(ctx context.Context, issuer string, client httpclient.Client) (DiscoveredEndpoints, error)

type OAuthError

type OAuthError struct {
	Error       string `json:"error"`
	Description string `json:"error_description,omitempty"`
}

type OIDCProviderMetadata

type OIDCProviderMetadata struct {
	Issuer                                 string   `json:"issuer"`
	AuthorizationEndpoint                  string   `json:"authorization_endpoint"`
	TokenEndpoint                          string   `json:"token_endpoint"`
	UserinfoEndpoint                       string   `json:"userinfo_endpoint"`
	RevocationEndpoint                     string   `json:"revocation_endpoint"`
	JWKSURI                                string   `json:"jwks_uri"`
	ResponseTypesSupported                 []string `json:"response_types_supported"`
	GrantTypesSupported                    []string `json:"grant_types_supported"`
	SubjectTypesSupported                  []string `json:"subject_types_supported"`
	IDTokenSigningAlgValuesSupported       []string `json:"id_token_signing_alg_values_supported"`
	ScopesSupported                        []string `json:"scopes_supported"`
	ClaimsSupported                        []string `json:"claims_supported"`
	CodeChallengeMethodsSupported          []string `json:"code_challenge_methods_supported"`
	TokenEndpointAuthMethodsSupported      []string `json:"token_endpoint_auth_methods_supported"`
	RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported"`
}

func BuildOIDCMetadata

func BuildOIDCMetadata(issuer, apiBase string) OIDCProviderMetadata

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL