auth

package
v0.0.0-...-eaf0aa9 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2014 License: BSD-3-Clause Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BUILTIN = "built-in"
	OAUTH2  = "oauth2"
	LDAP    = "ldap"
	NIS     = "nis"
)

authentication strategy keys

View Source
const (
	SALT_ENTROPY             = 3
	BERR_INVALID_CREDENTIALS = "Invalid username or password"
)
View Source
const (
	LOGIN_PATH = "/login"
)

Variables

View Source
var (
	ErrInvalidUsernameOrPassword = errors.New("Invalid username or password")
	ErrUsernameExists            = errors.New("Username already exists")
)

Functions

func AddStrategy

func AddStrategy(name string, newfunc NewStrategyFunc)

TODO: use RWMutex in case this is called from different goroutines

func Login

func Login(w http.ResponseWriter, r *perfect.Request)

func Protect

A handler that filters all requests that have not been authenticated returns 401 Unauthorized if the user's session hasn't been marked as authenticated

Types

type BuiltinStrategy

type BuiltinStrategy struct {
	Config *Config
}

func NewBuiltinStrategy

func NewBuiltinStrategy(config *Config) *BuiltinStrategy

func (*BuiltinStrategy) Attach

func (b *BuiltinStrategy) Attach(module *perfect.Module)

func (*BuiltinStrategy) Login

func (b *BuiltinStrategy) Login(w http.ResponseWriter, r *perfect.Request) (profile_id *string, err error)

func (*BuiltinStrategy) LoginPage

func (b *BuiltinStrategy) LoginPage(w http.ResponseWriter, r *perfect.Request)

func (*BuiltinStrategy) Logout

default logout

func (*BuiltinStrategy) Register

func (b *BuiltinStrategy) Register(w http.ResponseWriter, r *perfect.Request)

func (*BuiltinStrategy) RegistrationPage

func (b *BuiltinStrategy) RegistrationPage(w http.ResponseWriter, r *perfect.Request)

type Config

type Config struct {
	Type              string `json:"type,omitempty"`
	AllowRegistration bool   `json:"allow_registration,omitempty"`
	Username          string `json:"username,omitempty"`
	Password          string `json:"password,omitempty"`
	Name              string `json:"name,omitempty"`
	Email             string `json:"email,omitempty"`
}

type NewStrategyFunc

type NewStrategyFunc func(config *Config) Strategy

type Strategy

type Strategy interface {
	Attach(module *perfect.Module)

	LoginPage(w http.ResponseWriter, r *perfect.Request)
	RegistrationPage(w http.ResponseWriter, r *perfect.Request)

	Login(w http.ResponseWriter, r *perfect.Request) (profile_id *string, err error)
	Register(w http.ResponseWriter, r *perfect.Request)
	Logout(w http.ResponseWriter, r *perfect.Request)
}

func New

func New(config *Config) Strategy

func NewBuiltinStrategyFunc

func NewBuiltinStrategyFunc(config *Config) Strategy

Jump to

Keyboard shortcuts

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