Back to godoc.org

Package auth

v0.0.2
Latest Go to latest

The latest major version is .

Published: Sep 19, 2018 | License: MIT | Module: gitee.com/go-admin/go-admin.git

Index

Variables

var TokenHelper = new(CSRFToken)

func CheckPermissions

func CheckPermissions(user User, path string, method string) bool

func ComparePassword

func ComparePassword(comPwd, pwdHash string) bool

func DelCookie

func DelCookie(ctx *context.Context) bool

func EncodePassword

func EncodePassword(pwd []byte) string

func GetPermissions

func GetPermissions(role_id interface{}) []map[string]interface{}

func InMethodArr

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

func SetCookie

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

type CSRFToken

type CSRFToken []string

func (*CSRFToken) AddToken

func (token *CSRFToken) AddToken() string

func (*CSRFToken) CheckToken

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

type Config

type Config struct {
	Expires time.Duration
	Cookie  string
}

type Invoker

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

func SetPrefix

func SetPrefix(prefix string) *Invoker

func (*Invoker) Middleware

func (invoker *Invoker) Middleware(h context.Handler) 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 Permission

type Permission struct {
	Method []string
	Path   []string
}

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
}

type User

type User struct {
	ID          string
	Level       string
	Name        string
	LevelName   string
	CreateAt    string
	Avatar      string
	Permissions []Permission
	Menus       []int64
}

func Check

func Check(password string, username string) (user User, ok bool)

func Filter

func Filter(ctx *context.Context) (User, bool, bool)

func GetCurUserById

func GetCurUserById(id string) (user User, ok bool)

func (User) IsSuperAdmin

func (user User) IsSuperAdmin() bool

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier