login

package module
v0.0.0-...-aeca20e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const MAX_CSRF_TOKEN_SECONDS = 300

Variables

View Source
var BadUserError = sql.BadUserError
View Source
var GenerateCookieKey = crypto.GenerateCookieKey
View Source
var NewEmail = sql.NewEmail
View Source
var NewSqlUserDB = sql.NewSqlUserDB
View Source
var SetCookieKey = crypto.SetCookieKey

Functions

func GetGoogKeysJson

func GetGoogKeysJson() (string, error)

Fetch latest google oauth keys.

func LogoutHandler

func LogoutHandler(out http.ResponseWriter, request *http.Request)

Clear cookie. Redirect to /

func MakeHttpCookie

func MakeHttpCookie(xuc string) *http.Cookie

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 OauthConfig = oauth.Config

type User

type User = sql.User

func GetHttpUser

func GetHttpUser(out http.ResponseWriter, request *http.Request, udb UserDB) (*User, error)

Checkes request for cookier or form login. May set cookie in response if form login is successful.

type UserDB

type UserDB = sql.UserDB

type UserSocial

type UserSocial = sql.UserSocial

Directories

Path Synopsis
sql

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL