scimtoken

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: GPL-3.0 Imports: 4 Imported by: ? 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

Overview

Package scimtoken is the domain model for per-tenant SCIM 2.0 provisioning bearer tokens (RFC-009). Only the peppered hash is persisted; the plaintext is shown once at creation.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("scim token not found")

ErrNotFound is returned when no token matches the lookup.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	Create(ctx context.Context, token *ScimToken) error
	// GetByHash returns the token with the given peppered hash (used on the
	// authentication path). Returns ErrNotFound when absent.
	GetByHash(ctx context.Context, tokenHash string) (*ScimToken, error)
	GetByID(ctx context.Context, tenantID, id shared.ID) (*ScimToken, error)
	ListByTenant(ctx context.Context, tenantID shared.ID) ([]*ScimToken, error)
	Update(ctx context.Context, token *ScimToken) error
	// TouchLastUsed records a use time WITHOUT touching status, and only for a
	// still-active token. This avoids a last-used write on the auth path
	// clobbering a concurrent revoke (which would resurrect the token).
	TouchLastUsed(ctx context.Context, id shared.ID, at time.Time) error
}

Repository persists SCIM tokens.

type ScimToken

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

ScimToken is a per-tenant SCIM bearer token.

func New

func New(id, tenantID shared.ID, name, tokenHash, prefix string) *ScimToken

New creates an active SCIM token.

func Reconstruct

func Reconstruct(id, tenantID shared.ID, name, tokenHash, prefix string, status Status, createdBy *shared.ID, createdAt time.Time, lastUsedAt *time.Time) *ScimToken

Reconstruct rebuilds a token from persistence.

func (*ScimToken) CreatedAt

func (t *ScimToken) CreatedAt() time.Time

func (*ScimToken) CreatedBy

func (t *ScimToken) CreatedBy() *shared.ID

func (*ScimToken) ID

func (t *ScimToken) ID() shared.ID

func (*ScimToken) IsActive

func (t *ScimToken) IsActive() bool

IsActive reports whether the token may authenticate.

func (*ScimToken) LastUsedAt

func (t *ScimToken) LastUsedAt() *time.Time

func (*ScimToken) Name

func (t *ScimToken) Name() string

func (*ScimToken) Prefix

func (t *ScimToken) Prefix() string

func (*ScimToken) Revoke

func (t *ScimToken) Revoke()

Revoke marks the token unusable.

func (*ScimToken) SetCreatedBy

func (t *ScimToken) SetCreatedBy(id shared.ID)

SetCreatedBy records the admin who minted the token.

func (*ScimToken) Status

func (t *ScimToken) Status() Status

func (*ScimToken) TenantID

func (t *ScimToken) TenantID() shared.ID

func (*ScimToken) TokenHash

func (t *ScimToken) TokenHash() string

func (*ScimToken) TouchLastUsed

func (t *ScimToken) TouchLastUsed(at time.Time)

TouchLastUsed records a successful authentication time.

type Status

type Status string

Status is the token lifecycle state.

const (
	StatusActive  Status = "active"
	StatusRevoked Status = "revoked"
)

Jump to

Keyboard shortcuts

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