token

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 11 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")
	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"`

	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 (*AccessTokenRevocations) Check added in v0.13.0

func (r *AccessTokenRevocations) Check(
	ctx context.Context,
	accessToken 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, accessToken string, 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 (*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) 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 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