paseto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTokenExpired is returned when a valid token is past its expiry time.
	ErrTokenExpired = errors.New("paseto: token expired")

	// ErrTokenInvalid is returned when the token cannot be decrypted or parsed.
	ErrTokenInvalid = errors.New("paseto: token invalid")
)

Functions

func NewTokenParser

func NewTokenParser(key paseto.V4SymmetricKey) func(string) (*Claims, error)

NewTokenParser is a helper that returns a TokenParser function compatible with the auth middleware.

func Seal

func Seal(claims Claims, key paseto.V4SymmetricKey) (string, error)

Seal encrypts claims into a PASETO v4 local token string.

func V4SymmetricKeyFromHex

func V4SymmetricKeyFromHex(hexKey string) (paseto.V4SymmetricKey, error)

V4SymmetricKeyFromHex is a helper that parses a hex-encoded string into a paseto.V4SymmetricKey.

Types

type Claims

type Claims struct {
	IssuedAt  time.Time `json:"iat"`
	ExpiresAt time.Time `json:"exp"`
	TenantID  string    `json:"tenant_id"`
	UserID    string    `json:"user_id"`
	Role      string    `json:"role"`
}

Claims holds the application-specific payload embedded in the token.

func Parse

func Parse(tokenStr string, key paseto.V4SymmetricKey) (*Claims, error)

Parse decrypts and validates a token, returning the embedded Claims.

Jump to

Keyboard shortcuts

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