Documentation ¶
Overview ¶
Package oauth2 contains Martini handlers to provide user login via an OAuth 2.0 backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // PathLogin is the path to handle OAuth 2.0 logins. PathLogin = "/login" // PathLogout is the path to handle OAuth 2.0 logouts. PathLogout = "/logout" // PathCallback is the path to handle callback from OAuth 2.0 backend // to exchange credentials. PathCallback = "/oauth2callback" // PathError is the path to handle error cases. PathError = "/oauth2error" )
View Source
var LoginRequired = func() martini.Handler { return func(s sessions.Session, c martini.Context, w http.ResponseWriter, r *http.Request) { token := unmarshallToken(s) if token == nil || token.Expired() { next := url.QueryEscape(r.URL.RequestURI()) http.Redirect(w, r, PathLogin+"?next="+next, codeRedirect) } } }()
Handler that redirects user to the login page if user is not logged in. Sample usage: m.Get("/login-required", oauth2.LoginRequired, func() ... {})
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.