Packages

Native Elixir authentication compatible with datadeft-auth Rust.

Current section

Files

Jump to
datadeft_auth ADMIN-PARITY.md
Raw

ADMIN-PARITY.md

# Audited account administration

Scope: the owner-approved [Elixir parity plan](../../docs/elixir-0.8-plan.md)
and the owner's instruction to complete all parity features in draft #45.

1. **Problem.** Elixir operators need to disable an account and terminate
   its sessions, then restore login without restoring any previous session.
2. **Existing implementation.** Rust `AuthAdminService` and the DynamoDB
   admin repository define the operations and audit records. Elixir already
   enforces the authoritative disabled flag and session watermark on every
   login and session validation respectively.
3. **Gap.** Elixir cannot safely mutate that flag or write the Rust audit trail.
   Setting the flag out of band can restore sessions or undo a concurrent disable.
4. **Smallest solution.** Implement the Rust audited transactions and service
   ordering over the existing DynamoDB table and injected clock. The app owns
   authorization, UI, and identity for the actor. No admin HTTP routes,
   additional table/index, GSI, secret, or dependency.
5. **Cost.** The admin API and parity tests become maintained surfaces.
   Bulk revocation reads the whole user session index; only sessions that
   may still validate get a write. Partial bulk failure is retryable.
6. **Proof.** Exercise atomic state/audit writes, repeat disable, interrupted
   revocation, skewed sessions, conditional enable fences, and login races
   through DynamoDB Local. Inspect the audit rows using the Rust contract.

Pass `{DatadeftAuth.AWS.DynamoDB.Admin, store}` to
`DatadeftAuth.MagicLink.Service.Admin`. Use a clock returning
`{:ok, unix_seconds}` and `Admin.Actor.new/2` with the ID assigned by the
application's admin authorization. Do not pass identity from an untrusted
request. No admin routes are mounted by the library.

Disable is visible to session validation before bulk revocation starts. A
failed bulk revocation can be retried without enabling the account. Enable
first completes revocation, then sets a watermark and clears the disabled
state only while the profile's version still matches. Repeat disable keeps the
original disabled timestamp and actor but appends an audit entry and bumps
the version every time.

List operations return authoritative profile or session records and audit
events using the Rust schema. Use the opaque `next` cursor even if a scan page
is empty. Session handles are not bearer credentials; show the short label
from `Admin.SessionSummary.display_id/1` and send the full handle to
`Admin.revoke_session/5`. Active-session scans are informational, not an
authorization check.