usersession

package
v1.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Overview

Package usersession contains the logic for usersession handling. This includes the usersession handling, the sign-in and the sign-out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSigninHandler

func NewSigninHandler(handler Handler, auth Auth) http.Handler

NewSigninHandler creates a new signin handler that handles signin requests from the client.

func NewSignoutHandler

func NewSignoutHandler(handler Handler) http.Handler

NewSignoutHandler creates a new signout handler that handles signout requests from the client.

Types

type Auth

type Auth interface {
	// Validate validates user credentials and returns the corresponding user.
	//
	// If the credentials are invalid false and nil(for user and error) will be
	// returned.
	//
	// If a real error happens during validation it will be returned and the
	// user will be nil and the bool false.
	Validate(identifier string, password string) (*user.User, bool, error)
}

Auth is used to authenticate users.

type Handler

type Handler interface {
	// StartFor starts the session for given user.
	StartFor(w http.ResponseWriter, r *http.Request, u *user.User) error
	// EndFor ends the session for given user.
	EndFor(w http.ResponseWriter, r *http.Request, u *user.User) error
	// GetCurrent gets the user that hold the session. If there is no
	// user session the returned user will be nil.
	GetCurrent(r *http.Request) (*user.User, error)
}

Handler is used to start sessions for a user and end them.

Jump to

Keyboard shortcuts

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