Documentation ¶
Index ¶
Constants ¶
View Source
const (
GoogleOAuthEmailScope = "https://www.googleapis.com/auth/userinfo.email" // WTF to get this
)
Variables ¶
View Source
var ( // FacebookClientID and FacebookClientSecret are credentials you'll // get when you setup OAuth2 logins on the facebook side. You *must* // specify these two values. FacebookClientID string FacebookClientSecret string )
View Source
var ( // GoogleClientID and GoogleClientSecret are credentials you'll get // when you setup OAuth2 logins on the google side. You *must* // specify these two values. GoogleClientID string GoogleClientSecret string )
View Source
var ( // The caller should configure these values. Note that the URLs need // to be added to your Google and Facebook setups, as allowed // referrers. Host = "https://stop.jetnoise.net" RedirectUrlStem = "/login" // oauth2 callbacks will register under here AfterLoginRelativeUrl = "/" // where the user finally ends up, after being logged in OnSuccessCallback Oauth2SucessCallback // Individual oauth2 systems Goauth2 Oauth2er Fboauth2 Oauth2er )
Functions ¶
func NewOauth2Handler ¶
func NewOauth2Handler(oauth2 Oauth2er) func(w http.ResponseWriter, r *http.Request)
Returns a standard requesthandler. When run, it handles the redirect from the oauth2 provider, and if it gets an email address from the provider, will invoke the callback function with it, before redirecting to the provided URL.
Types ¶
type FacebookOauth2 ¶
func NewFacebookOauth2 ¶
func NewFacebookOauth2() FacebookOauth2
func (FacebookOauth2) CallbackToEmail ¶
func (fboauth2 FacebookOauth2) CallbackToEmail(r *http.Request) (string, error)
func (FacebookOauth2) GetLoginUrl ¶
func (fboauth2 FacebookOauth2) GetLoginUrl(w http.ResponseWriter, r *http.Request) string
If the user wants to login via facebook, we will redirect them to this URL
func (FacebookOauth2) GetLogoutUrl ¶
func (fboauth2 FacebookOauth2) GetLogoutUrl(w http.ResponseWriter, r *http.Request) string
We don't use this, as we don't have users juggling FB accounts and getting confused the way we do with Google accounts
func (FacebookOauth2) Name ¶
func (fb FacebookOauth2) Name() string
type GoogleOauth2 ¶
func NewGoogleOauth2 ¶
func NewGoogleOauth2() GoogleOauth2
func (GoogleOauth2) CallbackToEmail ¶
func (goauth2 GoogleOauth2) CallbackToEmail(r *http.Request) (string, error)
func (GoogleOauth2) GetLoginUrl ¶
func (goauth2 GoogleOauth2) GetLoginUrl(w http.ResponseWriter, r *http.Request) string
func (GoogleOauth2) GetLogoutUrl ¶
func (goauth2 GoogleOauth2) GetLogoutUrl(w http.ResponseWriter, r *http.Request) string
func (GoogleOauth2) Name ¶
func (g GoogleOauth2) Name() string
type Oauth2SucessCallback ¶
Click to show internal directories.
Click to hide internal directories.