token

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 5 Imported by: 0 modules, 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

View Source
var (
	ErrInvalidToken         = errors.New("invalid access token")
	ErrExpiredToken         = errors.New("expired access token")
	ErrUnknownKey           = errors.New("unknown signing key")
	ErrInvalidClaims        = errors.New("invalid token claims")
	ErrInvalidRoleNamespace = errors.New("invalid role namespace")
)

Functions

This section is empty.

Types

type AccessClaims

type AccessClaims struct {
	SessionID uuid.UUID    `json:"sid"`
	Roles     []roles.Role `json:"roles"`

	jwt.RegisteredClaims
}

type AccessTokenService

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

func NewAccessTokenService

func NewAccessTokenService(
	keys *KeySet,
	issuer string,
	ttl time.Duration,
) *AccessTokenService

func (*AccessTokenService) Generate

func (s *AccessTokenService) Generate(userID uuid.UUID, sessionId uuid.UUID, audience Audience, roles roles.Roles, now time.Time) (string, error)

func (*AccessTokenService) Parse

func (s *AccessTokenService) Parse(tokenString string, expectedAudience Audience, now time.Time) (*AccessClaims, error)

func (*AccessTokenService) ParseAny added in v0.1.13

func (s *AccessTokenService) ParseAny(tokenString string, now time.Time) (*AccessClaims, error)

type Audience

type Audience string
const (
	AudienceApp   Audience = "app"
	AudienceAdmin Audience = "admin"
)

type KeySet

type KeySet struct {
	ActiveKeyID string
	Keys        map[string][]byte
}

func NewKeySet

func NewKeySet(activeKeyID string, keys map[string][]byte) (*KeySet, error)

func (*KeySet) SigningKey

func (k *KeySet) SigningKey() (keyID string, key []byte)

func (*KeySet) VerificationKey

func (k *KeySet) VerificationKey(keyID string) ([]byte, bool)

Jump to

Keyboard shortcuts

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