Documentation ¶
Index ¶
- func ContextWithToken(ctx context.Context, tkn *oauth2.Token) context.Context
- func NewLoginHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig) http.HandlerFunc
- func NewTokenHandler(cfg *oauth2.Config, ckCfg *autho.CookieConfig, ...) http.Handler
- func TokenFromContext(ctx context.Context) (*oauth2.Token, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithToken ¶
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
Types ¶
This section is empty.