Documentation ¶
Index ¶
- Variables
- type CodeVerifier
- type OIDCProvider
- func (pc *OIDCProvider) AuthCodeURLWithPKCE(state string) (string, string)
- func (pc *OIDCProvider) ExchangeWithPKCE(ctx context.Context, authCode, codeVerifier string) (*oauth2.Token, error)
- func (pc OIDCProvider) GetConfig() *oauth2.Config
- func (pc *OIDCProvider) Verify(ctx context.Context, rawIDToken string) (*oidc.IDToken, error)
Constants ¶
This section is empty.
Variables ¶
var (
DefaultScopes = []string{oidc.ScopeOpenID, oidc.ScopeOfflineAccess, "profile", "email", "groups", "audience:server:client_id:epinio-api", "federated:id"}
)
Functions ¶
This section is empty.
Types ¶
type CodeVerifier ¶
type CodeVerifier struct {
Value string
}
CodeVerifier is an helper struct used to create a code_challenge for the PKCE Ref: https://www.oauth.com/oauth2-servers/pkce/
func NewCodeVerifier ¶
func NewCodeVerifier() *CodeVerifier
NewCodeVerifier returns a cryptographic secure random CodeVerifier of a fixed length (32)
func NewCodeVerifierWithLen ¶
func NewCodeVerifierWithLen(len int) *CodeVerifier
NewCodeVerifier returns a cryptographic secure random CodeVerifier of the specified length
func (*CodeVerifier) ChallengeS256 ¶
func (c *CodeVerifier) ChallengeS256() string
ChallengeS256 returns an encoded SHA256 code_challenge of the code_verifier
type OIDCProvider ¶
type OIDCProvider struct { Issuer string Endpoint *url.URL Provider *oidc.Provider Config *oauth2.Config P jInterfaces.PortalProxy }
OIDCProvider wraps an oidc.Provider and its Configuration
func NewOIDCProviderWithEndpoint ¶
func NewOIDCProviderWithEndpoint(p jInterfaces.PortalProxy, ctx context.Context, authEndpoint, issuer, uiUrl string) (*OIDCProvider, error)
NewOIDCProviderWithEndpoint construct an OIDCProvider fetching its configuration from the endpoint URL
func (*OIDCProvider) AuthCodeURLWithPKCE ¶
func (pc *OIDCProvider) AuthCodeURLWithPKCE(state string) (string, string)
AuthCodeURLWithPKCE will return an URL that can be used to obtain an auth code, and a code_verifier string. The code_verifier is needed to implement the PKCE auth flow, since this is going to be used by our CLI Ref: https://www.oauth.com/oauth2-servers/pkce/
func (*OIDCProvider) ExchangeWithPKCE ¶
func (pc *OIDCProvider) ExchangeWithPKCE(ctx context.Context, authCode, codeVerifier string) (*oauth2.Token, error)
ExchangeWithPKCE will exchange the authCode with a token, checking if the codeVerifier is valid
func (OIDCProvider) GetConfig ¶
func (pc OIDCProvider) GetConfig() *oauth2.Config