auth

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

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 v0.0.4

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 v0.0.5

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