auth

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: Apache-2.0 Imports: 20 Imported by: 40 modules, 116 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Middleware = DefaultInvoker().Middleware()
View Source
var TokenHelper = new(CSRFToken)

Functions

func Auth added in v1.0.0

func Auth(ctx *context.Context) models.UserModel

func Check

func Check(password string, username string) (user models.UserModel, ok bool)

func CheckPermissions

func CheckPermissions(user models.UserModel, path string, method string) bool

func DelCookie

func DelCookie(ctx *context.Context) bool

func EncodePassword

func EncodePassword(pwd []byte) string

func Filter

func Filter(ctx *context.Context) (models.UserModel, bool, bool)

func GetCurUserById

func GetCurUserById(id int64) (user models.UserModel, ok bool)

func InMethodArr

func InMethodArr(arr []string, str string) bool

func SetCookie

func SetCookie(ctx *context.Context, user models.UserModel) bool

Types

type CSRFToken

type CSRFToken []string

func (*CSRFToken) AddToken

func (token *CSRFToken) AddToken() string

func (*CSRFToken) CheckToken

func (token *CSRFToken) CheckToken(toCheckToken string) bool

type Config

type Config struct {
	Expires time.Duration
	Cookie  string
}

type Invoker

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

func DefaultInvoker added in v1.0.0

func DefaultInvoker() *Invoker

func SetPrefix

func SetPrefix(prefix string) *Invoker

func (*Invoker) Middleware

func (invoker *Invoker) Middleware() context.Handler

func (*Invoker) SetAuthFailCallback

func (invoker *Invoker) SetAuthFailCallback(callback MiddlewareCallback) *Invoker

func (*Invoker) SetPermissionDenyCallback

func (invoker *Invoker) SetPermissionDenyCallback(callback MiddlewareCallback) *Invoker

type MiddlewareCallback

type MiddlewareCallback func(ctx *context.Context)

type MysqlDriver

type MysqlDriver struct{}
var (
	Driver MysqlDriver
)

func (*MysqlDriver) Load

func (driver *MysqlDriver) Load(sid string) map[string]interface{}

func (*MysqlDriver) Update

func (driver *MysqlDriver) Update(sid string, values map[string]interface{})

type PersistenceDriver

type PersistenceDriver interface {
	Load(string) map[string]interface{}
	Update(sid string, values map[string]interface{})
}

type Session

type Session struct {
	Expires time.Duration
	Cookie  string
	Values  map[string]interface{}
	Driver  PersistenceDriver
	Sid     string
	Context *context.Context
}

func InitSession

func InitSession(ctx *context.Context) *Session

func (*Session) Clear

func (ses *Session) Clear()

func (*Session) Get

func (ses *Session) Get(key string) interface{}

func (*Session) Set

func (ses *Session) Set(key string, value interface{})

func (*Session) StartCtx

func (ses *Session) StartCtx(ctx *context.Context) *Session

func (*Session) UpdateConfig

func (ses *Session) UpdateConfig(config Config)

func (*Session) UseDatabase

func (ses *Session) UseDatabase(driver PersistenceDriver)

type SessionInterface

type SessionInterface interface {
	Get(string) interface{}
	Set(string, interface{})
	UseDatabase(PersistenceDriver)
	StartCtx(*context.Context) Session
}

Jump to

Keyboard shortcuts

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