token

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 13 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")
	ErrRevokedToken               = errors.New("revoked access token")
	ErrRevocationStoreUnavailable = errors.New("access-token revocation store unavailable")
	ErrInvalidRoleNamespace       = errors.New("invalid role namespace")
)

Functions

This section is empty.

Types

type AccessClaims

type AccessClaims struct {
	SessionID     uuid.UUID    `json:"sid"`
	OrgID         uuid.UUID    `json:"org_id"`
	OrgRole       string       `json:"org_role"`
	Roles         []roles.Role `json:"roles"`
	EmailVerified bool         `json:"email_verified"`

	jwt.RegisteredClaims
}

type AccessTokenRevocations added in v0.13.0

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

func NewAccessTokenRevocations added in v0.13.0

func NewAccessTokenRevocations(cache cache.Cache, ttl time.Duration) *AccessTokenRevocations

func NewAccessTokenRevocationsWithTTL added in v0.21.0

func NewAccessTokenRevocationsWithTTL(cache cache.Cache, ttl func() time.Duration) *AccessTokenRevocations

func (*AccessTokenRevocations) Check added in v0.13.0

func (r *AccessTokenRevocations) Check(
	ctx context.Context,
	_ string,
	claims *AccessClaims,
) error

func (*AccessTokenRevocations) RevokeMembership added in v0.13.0

func (r *AccessTokenRevocations) RevokeMembership(
	ctx context.Context,
	userID uuid.UUID,
	organizationID uuid.UUID,
	revokedAt time.Time,
) error

func (*AccessTokenRevocations) RevokeSession added in v0.13.0

func (r *AccessTokenRevocations) RevokeSession(ctx context.Context, sessionID uuid.UUID, revokedAt time.Time) error

func (*AccessTokenRevocations) RevokeToken added in v0.13.0

func (r *AccessTokenRevocations) RevokeToken(ctx context.Context, claims *AccessClaims, ttl time.Duration) error

func (*AccessTokenRevocations) RevokeUser added in v0.13.0

func (r *AccessTokenRevocations) RevokeUser(ctx context.Context, userID uuid.UUID, revokedAt time.Time) error

type AccessTokenService

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

func NewAccessTokenService

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

func NewAccessTokenServiceWithTTL added in v0.21.0

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

func (*AccessTokenService) Generate

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

func (*AccessTokenService) GenerateWithEmailVerification added in v0.22.0

func (s *AccessTokenService) GenerateWithEmailVerification(
	userID uuid.UUID,
	sessionID uuid.UUID,
	organizationID uuid.UUID,
	organizationRole string,
	audience Audience,
	roles roles.Roles,
	emailVerified bool,
	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"
	AudienceOperator Audience = "operator"
)

type JSONWebKey added in v0.25.0

type JSONWebKey struct {
	KeyType   string   `json:"kty"`
	KeyID     string   `json:"kid"`
	Use       string   `json:"use"`
	Algorithm string   `json:"alg"`
	Curve     string   `json:"crv"`
	X         string   `json:"x"`
	KeyOps    []string `json:"key_ops"`
}

type JSONWebKeySet added in v0.25.0

type JSONWebKeySet struct {
	Keys []JSONWebKey `json:"keys"`
}

type KeySet

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

func NewKeySet

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

NewKeySet constructs an Ed25519 signing key set from 32-byte private-key seeds. Public verification keys are derived and kept separately so they can be published without exposing private material.

func (*KeySet) ActiveKeyID

func (k *KeySet) ActiveKeyID() string

func (*KeySet) JWKS added in v0.25.0

func (k *KeySet) JWKS() JSONWebKeySet

func (*KeySet) SigningKey

func (k *KeySet) SigningKey() (keyID string, key ed25519.PrivateKey)

func (*KeySet) VerificationKey

func (k *KeySet) VerificationKey(keyID string) (ed25519.PublicKey, bool)

Jump to

Keyboard shortcuts

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