dex

package
v0.0.0-...-4aab545 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func (*OIDCProvider) Verify

func (pc *OIDCProvider) Verify(ctx context.Context, rawIDToken string) (*oidc.IDToken, error)

Verify will verify the token, and it will return an oidc.IDToken

Jump to

Keyboard shortcuts

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