Documentation ¶
Index ¶
Constants ¶
const ( DefaultServerAddress = "http://localhost:1234" DefaultSetPWPath = "/set-password" DefaultResetPWPath = "/reset-password" DefaultLoginPath = "/login" DefaultRedirectKey = "redirect" DefaultTokenKey = "jwt" )
Defaults when Forms.Paths is nil, or field is empty.
const ( // AllowedMethods for the handlers of this package AllowedMethods = http.MethodGet + " " + http.MethodPost )
const DefaultLoginTmpl = `` /* 545-byte string literal not displayed */
DefaultLoginTmpl is a placeholder template for `Login`
const DefaultResetPWTmpl = `` /* 419-byte string literal not displayed */
DefaultResetPWTmpl is a placeholder template for `Login`
const DefaultSetPWTmpl = `` /* 431-byte string literal not displayed */
DefaultSetPWTmpl is a placeholder template for `Login`
Variables ¶
var ( LoginTitle = "Please login" ResetPWTitle = "Reset password" SetPWTitle = "Set new password" )
Titles passed to templates
Functions ¶
This section is empty.
Types ¶
type FormData ¶
type FormData struct { Title string Flash *Flash SubmitURL string Data interface{} // As set on the Forms object }
FormData is passed to the form templates
type Forms ¶
type Forms struct { // Tmpl holds the login form template. // If nil a simple placholder is used. Tmpl *template.Template EP ehtml.Pages // Data will be available in all templates. Data interface{} Client auth.AuthenticatorClient Paths *Paths }
Forms implements http.Forms. A GET request serves the login form. A POST request processes user login.
func (*Forms) LoginHander ¶
LoginHander returns the handler taking care of login GET and POST requests. GET serves the "login" form template. POST checks the user's credentials over gRPC.
func (*Forms) ResetPWHandler ¶
ResetPWHandler returns the handler taking care of password setting, using a reset token. GET serves the "reset" form template. POST forwards the request over gPRC, which sends and an e-mail with a reset link to the submitted e-mail address, if it is registered.
func (*Forms) SetPWHandler ¶
SetPWHandler returns the handler taking care of password setting, using a reset token. GET serves the "setpw" form template. POST checks the JWT and sets the new password over gRPC.
type Paths ¶
type Paths struct { // Public address of the server. ServerAddress string `json:"server_address,omitempty"` SetPW string `json:"set_pw,omitempty"` ResetPW string `json:"reset_pw,omitempty"` Login string `json:"login,omitempty"` // RedirectKey for redirect URL in request Query. // Upon successfull authentication, the client is redirected to the URL under this key. // Login request: https://example.com/login?redirect=https://secured.com/admin?key=value // Will redirect to: https://secured.com/admin?key=value&jwt=xxxxxxxxxxx RedirectKey string `json:"redirect_key,omitempty"` // TokenKey is under which key the JSON web token will be embedded in the URL query, // when executing the redirect. TokenKey string `json:"token_key,omitempty"` }
Paths are used for generating Redirect responses, e-mailed links and route generation. All paths must be absolute, with leading slash.
type TemplateName ¶
type TemplateName string
TemplateName is used to predefine template naming requirements.
const ( LoginTmpl TemplateName = "login" ResetPWTmpl TemplateName = "reset" SetPWTmpl TemplateName = "setpw" )
Predefined Template Names.