auth

package
v0.260313.0-preview Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MPL-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	ClientID string `json:"client_id"`
	jwt.RegisteredClaims
}

Claims represents the JWT claims

type JWTManager

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

JWTManager manages JWT tokens

func NewJWTManager

func NewJWTManager(secretKey string) *JWTManager

NewJWTManager creates a new JWT manager

func (*JWTManager) GenerateAPIKey

func (j *JWTManager) GenerateAPIKey(clientID string) (string, error)

GenerateAPIKey generates a JWT token and encodes it with tingly-box- prefix

func (*JWTManager) GenerateToken

func (j *JWTManager) GenerateToken(clientID string) (string, error)

GenerateToken generates a new JWT token (24 hour expiry by default)

func (*JWTManager) GenerateTokenWithExpiry

func (j *JWTManager) GenerateTokenWithExpiry(clientID string, expiry time.Duration) (string, error)

GenerateTokenWithExpiry generates a new JWT token with custom expiry

func (*JWTManager) IsAPIKeyFormat

func (j *JWTManager) IsAPIKeyFormat(tokenString string) bool

IsAPIKeyFormat checks if the token follows API key format (tingly-box-xxx)

func (*JWTManager) ValidateAPIKey

func (j *JWTManager) ValidateAPIKey(tokenString string) (*Claims, error)

ValidateAPIKey validates an API key with tingly-box- prefix and returns JWT claims

func (*JWTManager) ValidateToken

func (j *JWTManager) ValidateToken(tokenString string) (*Claims, error)

ValidateToken validates a JWT token and returns the claims

Jump to

Keyboard shortcuts

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