Documentation ¶
Index ¶
- Constants
- Variables
- func GetGoogKeysJson() (string, error)
- func LogoutHandler(out http.ResponseWriter, request *http.Request)
- func MakeHttpCookie(xuc string) *http.Cookie
- func ParseConfigJSON(rin io.Reader) (map[string]OauthConfig, error)
- type EmailRecord
- type OauthCallbackHandler
- type OauthConfig
- type User
- type UserDB
- type UserSocial
Constants ¶
const MAX_CSRF_TOKEN_SECONDS = 300
Variables ¶
var BadUserError = sql.BadUserError
var GenerateCookieKey = crypto.GenerateCookieKey
var NewEmail = sql.NewEmail
var NewSqlUserDB = sql.NewSqlUserDB
var SetCookieKey = crypto.SetCookieKey
Functions ¶
func LogoutHandler ¶
func LogoutHandler(out http.ResponseWriter, request *http.Request)
Clear cookie. Redirect to /
func MakeHttpCookie ¶
func ParseConfigJSON ¶
func ParseConfigJSON(rin io.Reader) (map[string]OauthConfig, error)
Read JSON that should be a dict of {"service name":{oauth2.Config object}}e
Types ¶
type EmailRecord ¶
type EmailRecord = sql.EmailRecord
type OauthCallbackHandler ¶
type OauthCallbackHandler struct { Name string Config OauthConfig Udb sql.UserDB HomePath string ErrorPath string }
Handler for misc oauth login services. Google, fb, etc.
func BuildOauthMods ¶
func BuildOauthMods(configs map[string]OauthConfig, udb UserDB, homePath string, errPath string) ([]*OauthCallbackHandler, error)
Configs should be map[string]oauth2.Config from golang.org/x/oauth2 e.g. {"google":{"ClientID":"123-ABC.apps.googleusercontent.com", "ClientSecret":"12345", "Scopes": ["openid", "email"], "Endpoint":{"AuthURL":"https://accounts.google.com/o/oauth2/auth", "TokenURL":"https://accounts.google.com/o/oauth2/token"}, "RedirectURL":"https://myapp.com/login/google/callback"}}
See ParseConfigJSON
func (*OauthCallbackHandler) HandlerUrl ¶
func (cb *OauthCallbackHandler) HandlerUrl() string
local path which this Handler should register for
func (*OauthCallbackHandler) ServeHTTP ¶
func (cb *OauthCallbackHandler) ServeHTTP(out http.ResponseWriter, request *http.Request)
Redirect handler receives state and auth from server. config should point oauth other side at this
func (*OauthCallbackHandler) StartUrl ¶
func (cb *OauthCallbackHandler) StartUrl() string
Returns URL that user's browser should load to start auth
func (*OauthCallbackHandler) String ¶
func (cb *OauthCallbackHandler) String() string
type OauthConfig ¶
type User ¶
func GetHttpUser ¶
Checkes request for cookier or form login. May set cookie in response if form login is successful.
type UserSocial ¶
type UserSocial = sql.UserSocial