token

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Issuer = "utilInfo"
	Secret = "utilInfo"
)
View Source
const (
	ClaimsTypeRefresh = "RefreshToken"
	ClaimsTypeAccess  = "AccessToken"
)
View Source
const (
	TokenTypeBearer = "bearer"
)

Variables

View Source
var X gen

Functions

func FormatUUID

func FormatUUID(buf []byte) (string, error)

func GenBetterGUID

func GenBetterGUID() string

func GenKsuid

func GenKsuid() string

func GenSid

func GenSid() string

func GenSonyflake

func GenSonyflake() string

func GenUlid

func GenUlid() string

func GenXid

func GenXid() string

func GenerateRandomBytes

func GenerateRandomBytes(size int) ([]byte, error)

GenerateRandomBytes is used to generate random bytes of given size.

func GenerateRandomKey6

func GenerateRandomKey6() string

GenerateRandomKey6 生成6为随机字符串

func GenerateRandomKey16

func GenerateRandomKey16() string

GenerateRandomKey16 生成16为随机字符串

func GenerateRandomKey20

func GenerateRandomKey20() string

GenerateRandomKey20 生成20位随机字符串

func GenerateUUID

func GenerateUUID() (string, error)

GenerateUUID is used to generate a random UUID

func GetMD5Base64

func GetMD5Base64(bytes []byte) (base64Value string)

func GetMd5String

func GetMd5String(s string) string

func GetUUID

func GetUUID() (uuidHex string)

func New

func New() string

New Simple call

func NewShort

func NewShort() string

func NextStrToken

func NextStrToken() string

func NextToken

func NextToken() int64

func ParseUUID

func ParseUUID(uuid string) ([]byte, error)

func RandStringBytes

func RandStringBytes(n int) string

func SetPassword

func SetPassword(password string, salt string) (verify string, err error)

SetPassword 根据明文密码和加盐值生成密码

func UniqueId

func UniqueId() string

Types

type CustomClaims

type CustomClaims struct {
	Type string
	*Payload
	jwt.RegisteredClaims
}

func VerifyToken

func VerifyToken(token string, claimsType string) (*CustomClaims, error)

type CustomToken

type CustomToken struct {
	AccessToken  string    `json:"access_token"`
	TokenType    string    `json:"token_type"`
	ExpiresTime  time.Time `json:"expires_time"`
	RefreshToken string    `json:"refresh_token"`
	Payload      *Payload  `json:"payload"`
}

func GenerateToken

func GenerateToken(payload *Payload, accessTokenExpiresTime, refreshTokenExpiresTime time.Duration) (*CustomToken, error)

type ID

type ID struct {
	S       string
	Machine string
	PID     uint16
	Counter int32
}

type IdWorker

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

func (*IdWorker) InitIdWorker

func (this *IdWorker) InitIdWorker(workerId, datacenterId int64) error

func (*IdWorker) NextId

func (this *IdWorker) NextId() (int64, error)

type Payload

type Payload struct {
	UserID        string
	Username      string
	NickName      string
	UserStatus    int32
	UserType      int32
	AccountType   int32
	NamespaceIds  []string
	DownloadCount int
	Admin         string
}

type UUID

type UUID [16]byte

func NewUUID

func NewUUID() UUID

func (UUID) String

func (u UUID) String() string

Jump to

Keyboard shortcuts

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