Documentation
¶
Index ¶
- Variables
- func MarshalOptNoRefresh(t *Token)
- type AuthorizationGrantClient
- func (c *AuthorizationGrantClient) Authenticate(ctx context.Context) (*Token, error)
- func (c *AuthorizationGrantClient) Exchange(ctx context.Context, code string, codeVerifier string) (*oauth2.Token, error)
- func (c *AuthorizationGrantClient) GetAuthCodeURL(oauthMaterial *oauthMaterial) string
- func (c *AuthorizationGrantClient) RefreshToken(ctx context.Context, oldToken *Token) (*Token, error)
- func (c *AuthorizationGrantClient) ValidateState(ourState []byte, otherState []byte) error
- func (c *AuthorizationGrantClient) Verify(ctx context.Context, ourNonce []byte, rawIDToken string) (*oidc.IDToken, error)
- type Claims
- type Config
- type DeviceGrantClient
- type DeviceGrantConfig
- type MarshalOpts
- type Option
- type ServerConfig
- type Token
Constants ¶
This section is empty.
Variables ¶
var SetOauth2AuthStyle = func(authStyle oauth2.AuthStyle) Option { return func(c *AuthorizationGrantClient) { c.OauthConfig.Endpoint.AuthStyle = authStyle } }
var SetScopeOptions = func(scopes []string) Option { return func(c *AuthorizationGrantClient) { c.OauthConfig.Scopes = scopes } }
var SetSuccessMessage = func(successMessage string) Option { return func(c *AuthorizationGrantClient) { c.customMessages[oidcStatusSuccess] = successMessage } }
Functions ¶
Types ¶
type AuthorizationGrantClient ¶
type AuthorizationGrantClient struct {
OauthConfig *oauth2.Config
// contains filtered or unexported fields
}
AuthorizationGrantClient is an oauth client
func NewAuthorizationGrantClient ¶
func NewAuthorizationGrantClient(ctx context.Context, config *Config, clientOptions ...Option) (*AuthorizationGrantClient, error)
NewAuthorizationGrantClient returns a new client
func (*AuthorizationGrantClient) Authenticate ¶
func (c *AuthorizationGrantClient) Authenticate(ctx context.Context) (*Token, error)
Authenticate will authenticate authenticate with the idp
func (*AuthorizationGrantClient) Exchange ¶
func (c *AuthorizationGrantClient) Exchange(ctx context.Context, code string, codeVerifier string) (*oauth2.Token, error)
Exchange will exchange a token
func (*AuthorizationGrantClient) GetAuthCodeURL ¶
func (c *AuthorizationGrantClient) GetAuthCodeURL(oauthMaterial *oauthMaterial) string
GetAuthCodeURL gets the url to the oauth2 consent page
func (*AuthorizationGrantClient) RefreshToken ¶
func (c *AuthorizationGrantClient) RefreshToken(ctx context.Context, oldToken *Token) (*Token, error)
RefreshToken will fetch a new token
func (*AuthorizationGrantClient) ValidateState ¶
func (c *AuthorizationGrantClient) ValidateState(ourState []byte, otherState []byte) error
ValidateState validates the state from the authorize request
type Claims ¶
type Claims struct {
Issuer string `json:"iss"`
Audience string `json:"aud"`
Subject string `json:"sub"`
Name string `json:"name"`
AuthenticationMethods []string `json:"amr"`
Email string `json:"email"`
}
Claims represent the oidc token claims
type Config ¶
type Config struct {
ClientID string
IssuerURL string
ServerConfig *ServerConfig
}
Config is required to config a client
type DeviceGrantClient ¶
type DeviceGrantClient struct {
// contains filtered or unexported fields
}
DeviceGrantClient implements the OAuth 2.0 Device Authorization Grant flow
func NewDeviceGrantClient ¶
func NewDeviceGrantClient(ctx context.Context, config *DeviceGrantConfig) (*DeviceGrantClient, error)
NewDeviceGrantClient creates a new DeviceGrantClient
func (*DeviceGrantClient) Authenticate ¶
Authenticate initiates the device authorization flow and waits for user authentication
func (*DeviceGrantClient) RefreshToken ¶
RefreshToken will fetch a new token using the refresh token
type DeviceGrantConfig ¶
DeviceGrantConfig is required to configure a DeviceGrantClient
type Option ¶
type Option func(*AuthorizationGrantClient)
type ServerConfig ¶
ServerConfig is a server config
func (*ServerConfig) Validate ¶
func (c *ServerConfig) Validate() error
Validate validates the config
type Token ¶
type Token struct {
Version int
Expiry time.Time `json:"expires,omitempty"`
IDToken string `json:"token,omitempty"`
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
Claims Claims `json:"claims,omitempty"`
}
Token wraps the extracted claims, auth token, id token, refresh token so we can easily use it throughout our application
func TokenFromString ¶
func TokenFromString(tokenString *string, opts ...MarshalOpts) (*Token, error)