local

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 License: MIT Imports: 11 Imported by: 0

README

nibble-user-local-auth

Provides routes for authentication-related functions, as well as guards for routes based on authentication status. Login uses Basic auth.

Dependencies:

  • nibble-session
  • nibble-user
  • nibble-sendgrid

Some features:

  • login
  • logout
  • enforce logging on route
  • password reset
  • generate/validate password

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePasswordHash

func GeneratePasswordHash(password string) (string, error)

func ValidatePassword

func ValidatePassword(password string, hashedPassword string) (bool, error)

Types

type Extension

type Extension struct {
	nibbler.Extension

	SessionExtension *session.Extension
	UserExtension    *user.Extension

	// for emailing
	Sender outbound.Sender

	// for password reset
	PasswordResetEnabled             bool
	PasswordResetFromName            string
	PasswordResetFromEmail           string
	PasswordResetRedirect            string // a UI or other service to handle the redirect from email (will have ?token=X or &token=X appended)
	PasswordResetTokenExpirationDays *int

	// for email verification
	RegistrationEnabled                  bool
	EmailVerificationEnabled             bool // whether email verification is available (doesn't mean it's required)
	EmailVerificationRequired            bool // whether email verification is required before logging in
	EmailVerificationTokenExpirationDays *int
	EmailVerificationRedirect            string
	EmailVerificationFromName            string
	EmailVerificationFromEmail           string

	// callbacks (for extending default behavior)
	OnLoginSuccessful             *func(loggedInUser user.User, sessionMaxAgeMinutes int)
	OnLogoutSuccessful            *func(loggedOutUser user.User)
	OnRegistrationSuccessful      *func(registeredUser user.User)
	OnEmailVerificationSuccessful *func(registeredUser user.User)
	// contains filtered or unexported fields
}

func (*Extension) AddRoutes

func (s *Extension) AddRoutes(app *nibbler.Application) error

func (*Extension) Destroy

func (s *Extension) Destroy(app *nibbler.Application) error

func (*Extension) EmailTokenVerifyHandler added in v0.3.4

func (s *Extension) EmailTokenVerifyHandler(w http.ResponseWriter, r *http.Request)

func (*Extension) EnforceEmailValidated added in v0.4.0

func (s *Extension) EnforceEmailValidated(routerFunc func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

also validates the user is logged in

func (*Extension) EnforceLoggedIn

func (s *Extension) EnforceLoggedIn(routerFunc func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

func (*Extension) GetCurrentUserHandler added in v0.4.1

func (s *Extension) GetCurrentUserHandler(w http.ResponseWriter, r *http.Request)

func (*Extension) Init

func (s *Extension) Init(app *nibbler.Application) error

func (*Extension) Login

func (s *Extension) Login(email string, password string) (*user.User, error)

func (*Extension) LoginFormHandler

func (s *Extension) LoginFormHandler(w http.ResponseWriter, r *http.Request)

func (*Extension) LogoutHandler

func (s *Extension) LogoutHandler(w http.ResponseWriter, r *http.Request)

func (*Extension) RegisterFormHandler added in v0.3.4

func (s *Extension) RegisterFormHandler(w http.ResponseWriter, r *http.Request)

TODO: allow username

func (*Extension) ResetPasswordHandler

func (s *Extension) ResetPasswordHandler(w http.ResponseWriter, r *http.Request)

func (*Extension) ResetPasswordTokenHandler

func (s *Extension) ResetPasswordTokenHandler(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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