Documentation
¶
Overview ¶
Code generated by gowebx, DO AVOID EDIT.
Code generated by gowebx, DO AVOID EDIT.
Code generated by gowebx, DO AVOID EDIT.
Code generated by gowebx, DO AVOID EDIT.
Code generated by gowebx, DO AVOID EDIT.
Index ¶
- type AddTokenInput
- type Core
- func (c Core) AddToken(ctx context.Context, in *AddTokenInput) (*Token, error)
- func (c Core) DelAllForUser(ctx context.Context, scope, userID string) ([]string, error)
- func (c Core) DelExpired(ctx context.Context, before time.Time) ([]string, error)
- func (c Core) DelToken(ctx context.Context, id int) (*Token, error)
- func (c Core) DelayToken(ctx context.Context, token string, expire time.Time) error
- func (c Core) DelayTokenNow(ctx context.Context, token string, expire time.Time) error
- func (c Core) EditToken(ctx context.Context, in *EditTokenInput, id int) (*Token, error)
- func (c Core) Expire(ctx context.Context, scope string, userID string, reason string) ([]string, error)
- func (c Core) FindTokens(ctx context.Context, in *FindTokenInput) ([]*Token, int64, error)
- func (c Core) GetToken(ctx context.Context, id int) (*Token, error)
- func (c Core) Valid(ctx context.Context, token string) error
- type EditTokenInput
- type FindTokenInput
- type Storer
- type Token
- type TokenStorer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddTokenInput ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core business domain
func (Core) DelAllForUser ¶ added in v1.2.8
DelAllForUser 删除用户的所有 token
func (Core) DelExpired ¶
DelExpired 删除过期的 token
func (Core) DelayToken ¶
DelayToken 延迟 token,短期内只会延迟一次,expire 过期时间应该大于 10 分钟
func (Core) DelayTokenNow ¶
DelayTokenNow 立即延迟 token 过期时间
func (Core) Expire ¶ added in v1.2.8
func (c Core) Expire(ctx context.Context, scope string, userID string, reason string) ([]string, error)
Expire 主动过期
func (Core) FindTokens ¶
FindToken Paginated search
type EditTokenInput ¶
type FindTokenInput ¶
type Token ¶
type Token struct { ID int `gorm:"primaryKey" json:"id"` UserID string `gorm:"column:user_id;notNull;default:'';comment:用户标识" json:"user_id"` // 用户标识 Scope string `gorm:"column:scope;notNull;default:'';comment:应用场景" json:"scope"` // 应用场景 Hash []byte `gorm:"column:hash;notNull;comment:发给客户端的令牌 SHA-256 加密" json:"hash"` // 发给客户端的令牌 SHA-256 加密 CreatedAt orm.Time `gorm:"column:created_at;notNull;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt orm.Time `gorm:"column:updated_at;notNull;default:CURRENT_TIMESTAMP" json:"updated_at"` ExpiredAt orm.Time `gorm:"column:expired_at;notNull;default:CURRENT_TIMESTAMP;comment:过期时间" json:"expired_at"` // 过期时间 Reason string `gorm:"column:reason;notNull;default:''" json:"reason"` // 过期原因 }
Token domain model
type TokenStorer ¶
type TokenStorer interface { Find(context.Context, *[]*Token, orm.Pager, ...orm.QueryOption) (int64, error) Get(context.Context, *Token, ...orm.QueryOption) error Add(context.Context, *Token) error Edit(context.Context, *Token, func(*Token), ...orm.QueryOption) error Del(context.Context, *Token, ...orm.QueryOption) error DelExpired(ctx context.Context, before time.Time) ([]string, error) DelAllForUser(ctx context.Context, scope, userID string) ([]string, error) // 主动过期的函数,记录过期的原因,对用户友好 Expire(ctx context.Context, scope, userID, reason string) ([]string, error) }
TokenStorer Instantiation interface
Directories
¶
Path | Synopsis |
---|---|
store
|
|
tokencache
Code generated by gowebx, DO AVOID EDIT.
|
Code generated by gowebx, DO AVOID EDIT. |
tokendb
Code generated by gowebx, DO AVOID EDIT.
|
Code generated by gowebx, DO AVOID EDIT. |
Code generated by gowebx, DO AVOID EDIT.
|
Code generated by gowebx, DO AVOID EDIT. |
Click to show internal directories.
Click to hide internal directories.