authentication

package
v0.0.0-...-0c1db29 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LoginUrl     string
	ForbiddenURL string

	ForbiddenHandler http.HandlerFunc
)
View Source
var (
	// GetUser will be called to collect the user data
	GetUser func(r *http.Request) User
)
View Source
var GuestUser = NewUser()

Functions

func ClearUser

func ClearUser(cs *sessions.CookieStore, r *http.Request, w http.ResponseWriter)

func NewGetUser

func NewGetUser(cs *sessions.CookieStore) func(r *http.Request) User

NewGetUser allows you to generate a function which will retrieve user information from the given session.CookieStore

func SaveUser

func SaveUser(cs *sessions.CookieStore, r *http.Request, w http.ResponseWriter, u User)

Types

type Auth

type Auth struct {
	Perm Permission
}

func (*Auth) GET

func (a *Auth) GET(path string, h func(http.ResponseWriter, *http.Request, httprouter.Params))

func (*Auth) HandleFunc

func (a *Auth) HandleFunc(method, path string, h httprouter.Handle)

func (*Auth) IsAuthenticated

func (a *Auth) IsAuthenticated(u User) bool

func (*Auth) POST

func (a *Auth) POST(path string, h func(http.ResponseWriter, *http.Request, httprouter.Params))

type BasicUser

type BasicUser struct {
	// contains filtered or unexported fields
}

func (*BasicUser) Allow

func (u *BasicUser) Allow(p Permission)

func (*BasicUser) Disallow

func (u *BasicUser) Disallow(p Permission)

func (*BasicUser) GobDecode

func (u *BasicUser) GobDecode(b []byte) error

func (*BasicUser) GobEncode

func (u *BasicUser) GobEncode() ([]byte, error)

func (*BasicUser) Permissions

func (u *BasicUser) Permissions() map[Permission]bool

type Permission

type Permission uint8
const (
	// GuestPermission will be given to every single user by default
	GuestPermission Permission = 0
)

type User

type User interface {
	Permissions() map[Permission]bool
	Allow(Permission)
	Disallow(Permission)
}

func NewUser

func NewUser() User

Jump to

Keyboard shortcuts

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