token

package
v0.0.0-...-6269356 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAccessJWT

func GenerateAccessJWT(userID string, scope string) (string, error)

GenerateAccessJWT generates an access token with a short expiry time ~ 15 minutes

func GenerateHMACSignature

func GenerateHMACSignature(payload map[string]interface{}, privateKey string) string

GenerateHMACSignature generates the HMAC signature for the given payload using the private key. The signature is returned as a hex-encoded string.

func GeneratePairJWT

func GeneratePairJWT(userID string, scope string) (string, string, error)

GeneratePairJWT generates a pair of access and refresh tokens

func GeneratePrivateKey

func GeneratePrivateKey() (string, error)

GeneratePrivateKey generates a private key (Secret Key).

func GenerateRefreshJWT

func GenerateRefreshJWT(userID string, scope string) (string, error)

GenerateRefreshJWT generates a refresh token with a long expiry time >= 24 hours

func SortMapRecursively

func SortMapRecursively(m map[string]interface{}) map[string]interface{}

SortMapRecursively sorts a map recursively by its keys

func SortSliceRecursively

func SortSliceRecursively(s []interface{}) []interface{}

SortMapRecursively sorts a map recursively by its keys

func ValidateJWT

func ValidateJWT(tokenString string) (jwt.MapClaims, error)

ValidateJWT validates the JWT token string and returns the claims if valid.

func VerifyHMACSignature

func VerifyHMACSignature(payload map[string]interface{}, privateKey string, signature string) bool

VerifyHMACSignature verifies the HMAC signature for the given payload using the private key and returns true if the signature is valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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