auth

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("not supported")

Functions

func AuthMiddlewareFunc added in v0.1.6

func AuthMiddlewareFunc(af AuthFunc) iris.Handler

Types

type AuthFunc added in v0.1.6

type AuthFunc = func(ctx iris.Context) *User

type IUserModel added in v0.1.6

type IUserModel interface {
	GetID() string       // 用户id
	GetUsername() string // 用户名
	GetPhone() string    // 获取手机号
	IsAuthorized() bool  // 是否授权
}

数据库model

type User

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

实现 iris 的 User 接口: https://github.com/kataras/iris/blob/master/context/context_user.go

func GetUser added in v0.1.6

func GetUser(ctx iris.Context) *User

func (*User) GetAuthorization

func (u *User) GetAuthorization() (string, error)

GetAuthorization should return the authorization method, e.g. Basic Authentication.

func (*User) GetAuthorizedAt

func (u *User) GetAuthorizedAt() (time.Time, error)

func (*User) GetEmail

func (u *User) GetEmail() (string, error)

func (*User) GetField

func (u *User) GetField(key string) (interface{}, error)

func (*User) GetID

func (u *User) GetID() (string, error)

func (*User) GetPassword

func (u *User) GetPassword() (string, error)

func (*User) GetRaw

func (u *User) GetRaw() (interface{}, error)

GetRaw should return the raw instance of the user, if supported.

func (*User) GetRoles

func (u *User) GetRoles() ([]string, error)

func (*User) GetToken

func (u *User) GetToken() ([]byte, error)

func (*User) GetUserModel

func (u *User) GetUserModel() IUserModel

获取 UserModel

func (*User) GetUsername

func (u *User) GetUsername() (string, error)

func (*User) IsAuthorized

func (u *User) IsAuthorized() bool

func (*User) SetUserModel

func (u *User) SetUserModel(au IUserModel)

设置用户 UserModel

Jump to

Keyboard shortcuts

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