util

package
v0.0.0-...-63192da Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	T_cos *cos.Client = connectToTencentCOS()
)

Functions

func GenerateCode

func GenerateCode() string

GenerateCode generate a random code

func GenerateRandomString

func GenerateRandomString(length int) (string, error)

Generate random string

func GenerateToken

func GenerateToken(username string) (string, error)

GenerateToken token expireTime : not set, do this with redis

func GenerateTokenWithExp

func GenerateTokenWithExp(ctx context.Context, username string, expireTime time.Duration) (string, error)

GenerateToken with expireTime

func GenerateUUID

func GenerateUUID() string

Generate UUID

func GetUsername

func GetUsername(token, flag string) (string, error)

GetUsername flag: verify token type

func OutputHTML

func OutputHTML(w http.ResponseWriter, req *http.Request, filename string)

func PostWithHeader

func PostWithHeader(url string, header map[string]string, body any) (*http.Response, error)

func RefreshToken

func RefreshToken(token string) (string, error)

func SendEmail

func SendEmail(sender, secret, recipient, content, title string) error

sendEmail send email to user

func ShaHashing

func ShaHashing(in string) string

ShaHashing use sha512 to hash input.

Types

type JWTAccessClaims

type JWTAccessClaims struct {
	jwt.RegisteredClaims
}

JWTAccessClaims jwt claims

func ParseToken

func ParseToken(token string) (*JWTAccessClaims, error)

func (*JWTAccessClaims) Valid

func (a *JWTAccessClaims) Valid() error

type JWTAccessGenerate

type JWTAccessGenerate struct {
	SignedKeyID  string
	SignedKey    []byte
	SignedMethod jwt.SigningMethod
}

JWTAccessGenerate generate the jwt access token

func NewJWTAccessGenerate

func NewJWTAccessGenerate(kid string, key []byte, method jwt.SigningMethod) *JWTAccessGenerate

NewJWTAccessGenerate create to generate the jwt access token instance

func (*JWTAccessGenerate) Token

func (a *JWTAccessGenerate) Token(ctx context.Context, username string, expireTime time.Duration, isGenRenfresh bool) (string, string, error)

Token based on the UUID generate the jwt access token

Jump to

Keyboard shortcuts

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