auth

package
v1.261002.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 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 APITokenClaims added in v0.260418.2200

type APITokenClaims struct {
	UserID  string `json:"user_id"`
	TokenID string `json:"token_id"` // jti - for revocation check
	jwt.RegisteredClaims
}

APITokenClaims represents the JWT claims for API tokens

type APITokenManager added in v0.260418.2200

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

APITokenManager handles JWT token generation and validation for multi-tenant API tokens

func NewAPITokenManager added in v0.260418.2200

func NewAPITokenManager(config APITokenManagerConfig) (*APITokenManager, error)

NewAPITokenManager creates a new API token manager

func (*APITokenManager) GenerateToken added in v0.260418.2200

func (m *APITokenManager) GenerateToken(userUUID, tokenID string, expiresAt time.Time) (string, error)

GenerateToken generates a JWT token for a user

func (*APITokenManager) GetIssuer added in v0.260418.2200

func (m *APITokenManager) GetIssuer() string

GetIssuer returns the configured issuer

func (*APITokenManager) ValidateToken added in v0.260418.2200

func (m *APITokenManager) ValidateToken(tokenString string) (*APITokenClaims, error)

ValidateToken validates a JWT token and returns claims

type APITokenManagerConfig added in v0.260418.2200

type APITokenManagerConfig struct {
	SecretKey     string
	SigningMethod string // "HS256" or "RS256"
	Issuer        string // Default: "tingly-box"
}

APITokenManagerConfig holds configuration for APITokenManager

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