Documentation
¶
Overview ¶
Simple cookie and password based logins. See Init for required schema.
Index ¶
- func CSRFWrap(action string, handler http.Handler) http.Handler
- func CSRFWrapFunc(action string, fn http.HandlerFunc) http.Handler
- func ChangePassword(w http.ResponseWriter, r *http.Request) error
- func CheckCSRF(action string, r *http.Request) bool
- func Checker(handler http.Handler) http.Handler
- func CreateToken(userid int64) string
- func GetCSRF(action string, r *http.Request) string
- func Init(args InitArgs)
- func LoginFunc(w http.ResponseWriter, r *http.Request)
- func LogoutFunc(w http.ResponseWriter, r *http.Request)
- func Required(handler http.Handler) http.Handler
- func SetPassword(userid int64, newpass string) error
- func TokenRequired(handler http.Handler) http.Handler
- type InitArgs
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CSRFWrapFunc ¶
func CSRFWrapFunc(action string, fn http.HandlerFunc) http.Handler
func ChangePassword ¶
func ChangePassword(w http.ResponseWriter, r *http.Request) error
Change password helper. Requires oldpass and newpass form values. Requires logout csrf token.
func CreateToken ¶
func Init ¶
func Init(args InitArgs)
Init. Must be called with the database. Requires a users table with (userid, username, hash) columns and a auth table with (userid, hash, expiry) columns. Requires a config table with (key, value) ('csrfkey', some secret).
func LoginFunc ¶
func LoginFunc(w http.ResponseWriter, r *http.Request)
Default handler for /dologin Requires username and password form values. Redirects to SuccessUrl on success and /login on failure.
func LogoutFunc ¶
func LogoutFunc(w http.ResponseWriter, r *http.Request)
Handler for /dologout route.
Types ¶
type UserInfo ¶
represents a logged in user
func GetUserInfo ¶
Get UserInfo for this request, if any.
Click to show internal directories.
Click to hide internal directories.