auth

package
v0.4.14 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthBearer = "Bearer "
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InjectorFunc

type InjectorFunc func(ctx *gin.Context, ls *LoginStatus) (err error)

type LoginStatus

type LoginStatus struct {
	Token string
	Claim *UserClaims
	Err   error
	Role  Role
	State State
	// contains filtered or unexported fields
}

LoginStatus 登录状态

func (*LoginStatus) GetID

func (ls *LoginStatus) GetID(idname string) uint

GetID 获取ID

func (*LoginStatus) SetID

func (ls *LoginStatus) SetID(idname string, id uint)

SetID 设置ID

type LoginWay

type LoginWay uint8 // 登录方式
const (
	LoginWayUnknown LoginWay = 0
	// LoginWayEmail 邮箱+密码
	LoginWayEmail LoginWay = 1
	// LoginWayPhone 手机号+验证码
	LoginWayPhone LoginWay = 2
	// LoginWayWxWeb 微信网页端
	LoginWayWxWeb LoginWay = 3
	// LoginWayWxMp 微信公众号
	LoginWayWxMp LoginWay = 4
	// LoginWayWxMini 微信小程序
	LoginWayWxMini LoginWay = 5
	// LoginWayGithub github
	LoginWayGithub LoginWay = 6
	// LoginWayWorkWechat 企业微信
	LoginWayWorkWechat LoginWay = 7
)

type Role

type Role int
const (
	RoleNil Role = iota
	// RoleUser 普通用户
	RoleUser
	// RoleEmployee 运营用户
	RoleEmployee
	// RoleCustomer 客户
	RoleCustomer
)

type State

type State int
const (
	StateNil    State = 0
	StateSucc   State = 1
	StateFailed State = 2
)

type UserClaims added in v0.4.1

type UserClaims struct {
	// Uin 账号ID,主体+用户对应的唯一ID
	Uin uint `json:"c,omitempty"`

	// IssuedAt 创建时间
	IssuedAt int64 `json:"t,omitempty"`
	// ExpiresAt 过期时间
	ExpiresAt int64 `json:"e,omitempty"`
	// Issuer 签发者 区分不同签发者
	Issuer string `json:"i,omitempty"`
	// Audience 接收者
	Audience string `json:"a,omitempty"`
	// LoginWay 登录方式
	LoginWay LoginWay `json:"l,omitempty"`
}

UserClaims 用户信息

func (UserClaims) Valid added in v0.4.1

func (c UserClaims) Valid() error

Valid time based claims "exp, iat, nbf". There is no accounting for clock skew. As well, if any of the above claims are not in the token, it will still be considered a valid claim.

Jump to

Keyboard shortcuts

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