token

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AppSecret        = "v2ray"
	AppSecretRefresh = "v2rayRefresh"
)

AppSecret .

Functions

func ExtractRefreshTokenMetadata

func ExtractRefreshTokenMetadata(refreshToken string) (userID uint64, err error)

ExtractRefreshTokenMetadata refresh

func ExtractToken

func ExtractToken(r *http.Request) string

ExtractToken 从 requset 对象中解析出 token 字符串

func ValidToken

func ValidToken(r *http.Request) (err error)

ValidToken 验证 token 是否有效

func ValidWSToken

func ValidWSToken(r *http.Request) (err error)

ValidWSToken 验证 websocket 中的 token合法性。

func VerifyToken

func VerifyToken(r *http.Request) (token *jwt.Token, err error)

VerifyToken 验证 token 字符串的合法性

Types

type Token

type Token struct {
	AccessToken  string //访问令牌
	RefreshToken string // 刷新令牌
	AtExpires    int64  // 访问令牌过期时间,一般为 15 分钟。
	RtExpires    int64  // 当访问令牌过期后,可以使用刷新令牌来重拾。刷新令牌过期时间,一般为 7 天。
}

Token 基于 jwt token 的认证结构

func NewToken

func NewToken(userID uint64) (token *Token, err error)

NewToken 根据登录成功后的用户 id,创建 token。

Jump to

Keyboard shortcuts

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