token_revocations

This table stores revocation records used to invalidate active sessions or token-based access immediately, without waiting for natural token expiry.

Domain: Security / Session Control
Scope: Tenant
Status: Proposed
Last Updated: 11 Apr 2026
Mutable: Insert-mostly
Primary Owner: Auth / Middleware
RLS Applies: Usually backend-only
Client Facing: No

Purpose

The purpose of this table is to provide immediate access revocation for users, guests, or tenant-scoped sessions when suspension, logout enforcement, or emergency access removal is required.

What this table does

  • Stores revocation events that invalidate access
  • Supports forced logout and suspension flows
  • Allows middleware to reject requests even if a JWT is still technically valid
  • Supports immediate revocation for external guest access as well

Why this table is defined

JWTs and sessions often remain valid until expiry. DirtView needs a server-side mechanism to cut off access immediately when a user, tenant, or guest should no longer be allowed in the system.

Columns

Column Type Required Description Example
iduuidYesPrimary key for revocation recordtrev_001
user_iduuidYesUser whose token/session is revokeduser_123
tenant_iduuidYesTenant scope of the revocationtenant_001
reasontextYesWhy access was revokedmembership_suspended
revoked_attimestamptzYesWhen the revocation took effect2026-04-11 15:00:00+00
expires_attimestamptzNoOptional expiry for temporary revocation logicNULL
revoked_byuuidNoUser/admin who triggered revocationuser_admin_001
metadatajsonbYesOptional revocation details{"source":"tenant_suspension"}

Relationships

  • tenant_idtenants.id
  • user_id references a platform user
  • revoked_by references the actor who enforced revocation

How it is used

  • Checked by backend middleware on incoming authenticated requests
  • Used when suspending a tenant membership or external access grant
  • Used by force-logout workflows in admin systems
  • Used to invalidate access without waiting for token expiry

Access and security

  • This table is highly security-sensitive
  • Writes should be restricted to trusted services and admins
  • Checks should happen server-side, never only on the client
  • Revocation actions should themselves be audited

Example scenarios

Scenario 1: User suspension

A tenant admin suspends a user, and a revocation record is written immediately.

Scenario 2: External guest revoked

A project manager removes external access before the original expiry date.

Scenario 3: Forced logout

Support forces a logout for troubleshooting or after a security incident.

Notes and assumptions

  • This table is operational, not user-facing
  • Use indexes on (tenant_id, user_id, revoked_at desc)
  • Consider whether tenant-wide revocation needs a separate optimization path