Documentation ¶
Index ¶
- Variables
- func AuthURLHandler(w http.ResponseWriter, r *http.Request)
- func AuthenticateUser(username string, password string) error
- func CallbackURLHandler(w http.ResponseWriter, r *http.Request)
- func GetSession(w http.ResponseWriter, r *http.Request) string
- func New() *oauth2.Config
- func NewUser(username string, password string) error
- func OverrideOldPassword(username string, password string) error
- func ResetPassword(w http.ResponseWriter, r *http.Request)
- func SendPasswordResetEmail(email string) error
- func SetSession(w http.ResponseWriter, user string)
- func VerifyToken(r *http.Request) (string, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( // DB is the reference to our DB, which contains our user data. DB = newDB() // ErrUserAlreadyExists is the error thrown when a user attempts to create // a new user in the DB with a duplicate username. ErrUserAlreadyExists = errors.New("users: username already exists") // ErrUserNotFound is the error thrown when a user can't be found in the // database. ErrUserNotFound = errors.New("users: user not found") )
var CSRF = csrf.Protect(genRandBytes())
CSRF is used to prevent CSRF attacks
Functions ¶
func AuthURLHandler ¶
func AuthURLHandler(w http.ResponseWriter, r *http.Request)
AuthURLHandler just redirects the user to correct Oauth sign in page for our provider.
func AuthenticateUser ¶
AuthenticateUser accepts a username and password, and checks that the given password matches the hashed password. It returns nil on success, and an error on failure.
func CallbackURLHandler ¶
func CallbackURLHandler(w http.ResponseWriter, r *http.Request)
CallbackURLHandler handles all of the Oauth flow.
func GetSession ¶
func GetSession(w http.ResponseWriter, r *http.Request) string
GetSession gets the current session from the cookie
func OverrideOldPassword ¶
OverrideOldPassword overrides the old password with the new password. For use when resetting passwords.
func ResetPassword ¶
func ResetPassword(w http.ResponseWriter, r *http.Request)
ResetPassword is the HTTP handler that handles the password reset flow.
func SendPasswordResetEmail ¶
SendPasswordResetEmail sends a password reset email to the given user.
func SetSession ¶
func SetSession(w http.ResponseWriter, user string)
SetSession sets the session for the given user.