auth

package
v0.260224.1130 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

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 added in v0.260224.0

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