jwt

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IOTechIssuer = "IOTech"
)

Constants related to JWT

Variables

This section is empty.

Functions

func GetTokenStringFromRequest

func GetTokenStringFromRequest(r *http.Request) (string, errors.Error)

GetTokenStringFromRequest gets the token string from the request header

func ValidateToken

func ValidateToken(tokenString string, secretKey string) (string, string, errors.Error)

ValidateToken validates the given token string and gets the accessId and username.

Types

type TokenDetails

type TokenDetails struct {
	AccessId     string
	AccessToken  string
	AtExpires    int64
	RefreshId    string
	RefreshToken string
	RtExpires    int64
}

func CreateToken

func CreateToken(name string, atExpiresFromNow *int64, reExpiresFromNow *int64) (*TokenDetails, errors.Error)

CreateToken creates a new token with the given name and expiration time, specified in hours from now with the default expiration time of 2 hours for access token and 7 days for refresh token

Jump to

Keyboard shortcuts

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