jwt

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWKS

func GenerateJWKS(secretType string) (*jwk.Key, error)

GenerateJWKS creates a new JSON Web Key Set

Types

type CustomClaims

type CustomClaims struct {
	UserID       *string   `json:"user_id"`
	IsSubscribed *bool     `json:"is_subscribed"`
	Type         *string   `json:"type"`
	Roles        *[]string `json:"roles"`
	jwt.RegisteredClaims
}

CustomClaims represents the custom claims in the JWT

func ValidateToken

func ValidateToken(tokenString string, tokenType TokenType) (*CustomClaims, error)

ValidateToken verifies if a token is valid

type TokenDetails

type TokenDetails struct {
	Token     string
	TokenType TokenType
	ExpiresAt time.Time
	UserID    string
}

TokenDetails contains the token information

func GenerateToken

func GenerateToken(userID primitive.ObjectID, tokenType TokenType) (*TokenDetails, error)

GenerateToken creates a new JWT token

type TokenType

type TokenType string

TokenType represents the type of token

const (
	// AccessToken is used for authenticating requests
	AccessToken TokenType = "access"

	// RefreshToken is used to get a new access token
	RefreshToken TokenType = "refresh"
)

Jump to

Keyboard shortcuts

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