auth

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultUserHeaderKey = "REMOTE_USER"
View Source
const ENCRYPTION_TIMES = 10000

Variables

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

Functions

This section is empty.

Types

type AuthUser

type AuthUser struct {
	ID          string                `json:"id" gorm:"primaryKey"`
	Password    string                `json:"password"`
	Username    string                `json:"username" gorm:"unique"`
	IsSuperuser bool                  `json:"is_superuser"`
	Phone       string                `json:"phone"`
	IsActive    bool                  `json:"is_active"`
	CreatedAt   datatypes.IRFTime     `json:"created_at" gorm:"autoCreateTime"`
	IsDel       soft_delete.DeletedAt `json:"is_del" gorm:"softDelete:flag"`
}

用户表

type IAuth

type IAuth interface {
	Auth(ctx iris.Context)
}

type User

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

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

func NewUser

func NewUser(user_id string) *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() *AuthUser

获取 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 *AuthUser)

设置用户 UserModel

type UserIDAuth

type UserIDAuth struct {
}

使用header里面的 字段 remote_user 作为用户ID进行授权

func NewUserIDAuth

func NewUserIDAuth() *UserIDAuth

func (*UserIDAuth) Auth

func (a *UserIDAuth) Auth(ctx iris.Context)

Jump to

Keyboard shortcuts

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