Documentation ¶
Index ¶
- type BasicClient
- func (c *BasicClient) Exchange(ctx context.Context, code string) (*oauth2.Token, error)
- func (c *BasicClient) FormatRequest(state string, opts ...oauth2.AuthCodeOption) string
- func (c *BasicClient) UserInfo(ctx context.Context, token *oauth2.Token) (Claimer, error)
- func (c *BasicClient) VerifyIDToken(ctx context.Context, oauthToken OAuth2Token) (Claimer, error)
- type Claimer
- type Client
- type Config
- type MockClaimer
- type MockClient
- func (m *MockClient) Exchange(_ context.Context, _ string) (*oauth2.Token, error)
- func (m *MockClient) FormatRequest(_ string, options ...oauth2.AuthCodeOption) string
- func (m *MockClient) UserInfo(_ context.Context, _ *oauth2.Token) (Claimer, error)
- func (m *MockClient) VerifyIDToken(_ context.Context, _ OAuth2Token) (Claimer, error)
- type OAuth2Token
- type Provider
- type ProviderAdapter
- type Verifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicClient ¶
type BasicClient struct {
// contains filtered or unexported fields
}
BasicClient for OIDC.
func NewClient ¶
func NewClient(config *Config) *BasicClient
NewClient returns new BasicClient instance.
func (*BasicClient) FormatRequest ¶
func (c *BasicClient) FormatRequest(state string, opts ...oauth2.AuthCodeOption) string
FormatRequest returns a correctly-formatted OIDC request.
func (*BasicClient) VerifyIDToken ¶
func (c *BasicClient) VerifyIDToken(ctx context.Context, oauthToken OAuth2Token) (Claimer, error)
VerifyIDToken parses the id_token within the OAuth2 token and verifies it.
type Client ¶
type Client interface { FormatRequest(state string, opts ...oauth2.AuthCodeOption) string Exchange(c context.Context, code string) (*oauth2.Token, error) VerifyIDToken(c context.Context, oauthToken OAuth2Token) (Claimer, error) UserInfo(ctx context.Context, token *oauth2.Token) (Claimer, error) }
Client is capable of formatting authorization requests, exchanging the token grant for an access_token and id_token, and verifying id_tokens.
type Config ¶
type Config struct { TLSConfig *tls.Config Provider Provider CallbackURL string ClientID string ClientSecret string Scopes []string }
Config defines configuration for oidc client.
type MockClaimer ¶
MockClaimer can be a mock id_token or a mock UserInfo.
func (*MockClaimer) Claims ¶
func (m *MockClaimer) Claims(i interface{}) error
Claims scans the claims into 'i'.
type MockClient ¶
type MockClient struct { AuthRequest string OAuthToken *oauth2.Token OAuthErr error IDToken Claimer IDTokenErr error UserInfoVal Claimer UserInfoErr error }
MockClient is a mock OIDC client.
func (*MockClient) FormatRequest ¶
func (m *MockClient) FormatRequest(_ string, options ...oauth2.AuthCodeOption) string
FormatRequest formats the OIDC authorization request.
func (*MockClient) VerifyIDToken ¶
func (m *MockClient) VerifyIDToken(_ context.Context, _ OAuth2Token) (Claimer, error)
VerifyIDToken verifies the id_token inside the OAuth2 token.
type OAuth2Token ¶
OAuth2Token is the oauth2.Token.
type Provider ¶
type Provider interface { Endpoint() oauth2.Endpoint Verifier(*oidc.Config) Verifier UserInfo(context.Context, oauth2.TokenSource) (*oidc.UserInfo, error) }
Provider provides discovery of OIDC provider endpoints and also verifies id_tokens.
type ProviderAdapter ¶
ProviderAdapter adapts an *oidc.Provider into an OIDCProvider.
func (*ProviderAdapter) Endpoint ¶
func (o *ProviderAdapter) Endpoint() oauth2.Endpoint
Endpoint returns the OIDC endpoints.
func (*ProviderAdapter) UserInfo ¶
func (o *ProviderAdapter) UserInfo(ctx context.Context, ts oauth2.TokenSource) (*oidc.UserInfo, error)
UserInfo returns the user's info.
func (*ProviderAdapter) Verifier ¶
func (o *ProviderAdapter) Verifier(config *oidc.Config) Verifier
Verifier returns an OIDC verifier.