oauth2

package
v0.0.0-...-e4d3a07 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithToken

func ContextWithToken(ctx context.Context, tkn *oauth2.Token) context.Context

ContextWithToken is used by the token handler (default: oauth2.NewTokenHandler()) to set the oauth2 tokens under the context to be used by the user handler in exchange for the user resource.

func NewLoginHandler

func NewLoginHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig) http.HandlerFunc

NewLoginHandler creates a new LoginHandler which is resposible for setting a random value (state) to the state cookie. Afterwards the login handler is also responsible for redirecting the user to the provider for the users grant.

LoginHandler -> Provider (obtain grant)

func NewTokenHandler

func NewTokenHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig, errHandler, userHandler http.Handler) http.Handler

NewTokenHandler creates a new TokenHandler which is the first handler in the chain responding to the callback from the provider, it is responsible for parsing the response for auth code and state then comparing the cookie state with the request state. Following the parsing the TokenHandler performs the token exchange and adds the token to the request context, calling on success the UserHandler.

Provider -> TokenHandler -> UserHandler -> TermnialHandler

func TokenFromContext

func TokenFromContext(ctx context.Context) (*oauth2.Token, error)

TokenFromContext is used to harvest the tokens from the request context by the user handler and preform the token/user-resource exchange.

Types

This section is empty.

Jump to

Keyboard shortcuts

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