Documentation ¶
Overview ¶
Package oauthutil provides helpers for working with OAuth 2.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingOAuthConfig is returned when OAuth configuration has not been provided. ErrMissingOAuthConfig = errors.New("missing OAuth config") )
var ( // ErrMissingOAuthToken is returned when OAuth token has not been provided. ErrMissingOAuthToken = errors.New("missing OAuth token") )
Functions ¶
Types ¶
type FileStore ¶
type FileStore struct { // Directory credentials are stored. Directory string // Filename of credential being used. Filename string // contains filtered or unexported fields }
FileStore manages credentials locally.
func (*FileStore) Claims ¶
func (s *FileStore) Claims() (*oidcclaims.Claims, error)
Claims related to current token.
func (*FileStore) Login ¶
func (s *FileStore) Login(loginOpts *LoginOptions) error
Login authorizes the user and writes their token to the FileStore.
func (*FileStore) UpdateUserInfo ¶
UpdateUserInfo sets data returned by userinfo as claims.
type LoginOptions ¶
LoginOptions contain the configuration for the Authorize command.
func NewLoginOptions ¶
func NewLoginOptions() *LoginOptions
NewLoginOptions returns LoginOptions with defaults set.
type PKCEVerifier ¶ added in v1.0.1
type PKCEVerifier authhandler.PKCEParams
PKCEVerifier is a OAuth2 PKCE code verifier.
func Login ¶
func Login(opts *LoginOptions) (code string, verifier *PKCEVerifier, err error)
Login prompts users to authenticate with a browser.
func NewPKCEVerifier ¶ added in v1.0.1
func NewPKCEVerifier() *PKCEVerifier
NewPKCEVerifier returns a new code verifier.
func (*PKCEVerifier) AuthOpts ¶ added in v1.0.1
func (v *PKCEVerifier) AuthOpts() []oauth2.AuthCodeOption
AuthOpts returns the options to be passed to the OAuth2 authorization code flow from params.
func (*PKCEVerifier) TokenOpt ¶ added in v1.0.1
func (v *PKCEVerifier) TokenOpt() oauth2.AuthCodeOption
TokenOpt returns the options to be passed in the OAuth2 token exchange.
type Store ¶
type Store interface { oauth2.TokenSource Name() string Login(loginOpts *LoginOptions) error Claims() (*oidcclaims.Claims, error) UpdateUserInfo() error }
Store allows for login and accessing Tokens.