Documentation ¶
Overview ¶
Package oauth2 provides an handler for handling OAuth2 authentication flows and the implementation of several OAuth2 providers.
Index ¶
Constants ¶
View Source
const ( // DefaultCookieName is the name of the stored cookie DefaultCookieName = "browser_lter_session" // DefaultLifespan is the duration a token and cookie is valid DefaultLifespan = 48 * time.Hour // DefaultJWTIssuer is the default issuer of the JWT token DefaultJWTIssuer = "BrowserLTER" )
Variables ¶
View Source
var ( // ErrTokenInvalid denotes that a could not be validated. ErrTokenInvalid = errors.New("token is invalid") )
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface { // Validate returns an authenticated User if a valid user session is found. Validate(context.Context, *http.Request) (*browser.User, error) // Authorize will create a new user session for authenticated users. Authorize(context.Context, http.ResponseWriter, *browser.User) error // Expire will logout the authenticated User. Expire(http.ResponseWriter) }
Authenticator represents a service for authenticating users.
type Cookie ¶
type Cookie struct { // Secret used for JWT generation/validation. Secret string // Cookie used for storing JWT token in a secure manner. Cookie *securecookie.SecureCookie }
Cookie is an Authenticator using HTTP cookies and JWT tokens.
func (*Cookie) Expire ¶
func (c *Cookie) Expire(w http.ResponseWriter)
type Github ¶
Github is an OAuth2 provider for signing in using Github accounts.
type Google ¶
Google is an OAuth2 provider for signing in using Google accounts.
type Handler ¶
type Handler struct { Next http.Handler State string Nonce string Auth Authenticator Users browser.UserService // contains filtered or unexported fields }
Handler handles OAuth2 authorization flows and different account aspects.
type Microsoft ¶
type Microsoft struct { Provider string ClientID string Secret string RedirectURL string Nonce string }
Microsoft is an OAuth2 provider for signing in using azure AD.
type Provider ¶
type Provider interface { // Name returns the name of the provider. Name() string // Config returns the OAuth2 config of the provider. Config() *oauth2.Config // User returns user information from the provider. User(context.Context, *oauth2.Token) (*browser.User, error) }
Provider are the common parameters all OAuth2 providers should implement.
Click to show internal directories.
Click to hide internal directories.