Documentation
¶
Index ¶
- Variables
- func GetSession(r *http.Request) (*sessions.Session, error)
- func Logout(w http.ResponseWriter, r *http.Request)
- func Middleware(handler http.HandlerFunc, redirect string) http.HandlerFunc
- func SetSession(store *sessions.CookieStore)
- type AuthUser
- type Config
- func (c *Config) Copy() *Config
- func (c *Config) Exchange(ctx context.Context, code string) (*AuthUser, error)
- func (c *Config) GetSession(r *http.Request) (*sessions.Session, error)
- func (c *Config) GetUser(r *http.Request) (*User, error)
- func (c *Config) HandleAuthorizationRedirect() http.HandlerFunc
- func (c *Config) HandleLogin(redirect string, onLogins ...OnLoginFunc) http.HandlerFunc
- func (c *Config) Issuer() string
- func (c *Config) OAuth2() *oauth2.Config
- func (c *Config) UserInfoUrl() string
- type OnLoginFunc
- type Opts
- type User
Constants ¶
This section is empty.
Variables ¶
var ( //DefaultScopes are added if a Configs scopes are empty, they include: openid, email, profile DefaultScopes = []string{"openid", "email", "profile"} )
Functions ¶
func Logout ¶
func Logout(w http.ResponseWriter, r *http.Request)
Logout logs the user out so they cant pass the middleware without authenticating against at least one idp
func Middleware ¶
func Middleware(handler http.HandlerFunc, redirect string) http.HandlerFunc
Middleware wraps the http handler and redirects the user to the redirect if they are not logged in
func SetSession ¶
func SetSession(store *sessions.CookieStore)
SetSession overrides the default session store(recommended for production usage)
Types ¶
type AuthUser ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is used to to complete the Open ID Connect protocol using the Authorization Grant Authentication Flow.
func (*Config) Exchange ¶ added in v0.0.1
Exchange gets an AuthUser type by exchanging the authorization code for an access & id token, then calling the userinfo endpoint
func (*Config) HandleAuthorizationRedirect ¶
func (c *Config) HandleAuthorizationRedirect() http.HandlerFunc
HandleAuthorizationRedirect is an http handler that redirects the user to the identity providers login screen
func (*Config) HandleLogin ¶
func (c *Config) HandleLogin(redirect string, onLogins ...OnLoginFunc) http.HandlerFunc
HandleLogin gets the user from the request, executes the LoginHandler and then redirects to the input redirect
func (*Config) UserInfoUrl ¶
OAuth2 returns the Configs user info url returned from the discovery endpoint
type OnLoginFunc ¶
OnLoginFunc may be optionally passed into config.HandleLogin in order to execute additional logic against the user after the login occurs
type Opts ¶
type Opts struct {
// OpenID Connect describes a metadata document that contains most of the information required for an app to do sign-in.
// ex: https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration
DiscoveryUrl string `json:"discoveryUrl"`
// ClientID is the application's ID.
ClientID string `json:"clientID"`
// ClientSecret is the application's secret.
ClientSecret string `json:"clientSecret"`
// RedirectURL is the URL to redirect users going through
// the OAuth flow, after the resource owner's URLs.
Redirect string `json:"redirect"`
// Scope specifies optional requested permissions.
Scopes []string `json:"scopes"`
// SkipIssuerCheck skips the openid issuer check
SkipIssuerCheck bool `json:"skipIssuerCheck"`
}
Opts are options used when creating a new Configuration