Login using AWS
Sign up, sign in and password reset with AWS Cognito, integrated through standard OIDC.
DataData ModelSections
Data Model Designed
What the service keeps, how the pieces relate, and what every field means. The SQL is on the Schema tab.
Entities
User
A person who has signed in at least once with a verified email.
Has many sessions. Is referenced by every other service as owner_id, by value only.
identity.users
Session
One browser's proof of sign-in, valid for 7 days.
Belongs to one user. Deleted with the user.
identity.sessions
Signing key
The key pair that signs access tokens.
Stands alone. One is active at a time.
identity.signing_keys
Audit event
A permanent record that something happened.
Refers to a user and a target by ID, with no foreign key, so the record survives if the user is deleted.
identity.audit_events
Life of each record
- User
- Created at the first successful sign-in → lives until the account is deleted (Account management).
- Session
- Active from sign-in → ends when it is revoked (sign-out, password reset) or when 7 days pass, whichever is first. It is never reactivated.
- Signing key
- Active from creation → retired when a new key replaces it → still published for 10 minutes so recent tokens verify → no longer published.
- Access token
- Never stored. Created on request, valid for 5 minutes, checked by signature only.
Fields
identity.users
One row per person. Created the first time someone completes sign-in with a verified email.
iduuiddefault generated (UUIDv7)- The user's ID everywhere in 01scale. Other services store it as
owner_id. Never changes. - Primary key
cognito_subtext- Cognito's permanent ID for this person (the
subclaim). Used to find the user at sign-in. Not the email, because an email can change. - Unique. 1 to 255 characters
emailtext- The verified email address from Cognito. Shown in the UI and used by Delivery to send email.
- Unique ignoring case. Stored lower-cased. 3 to 254 characters and contains
@ email_verified_attimestamptz- When Identity first saw this email as verified. Always set, because unverified emails are refused.
is_adminbooleandefault false- Allows admin-only pages and endpoints. Set by hand in the database; there is no API to change it.
created_attimestamptzdefault now()- When the user first signed in. Shown as 'joined'.
identity.sessions
One row per browser sign-in. A request is signed in if its cookie matches a row that is neither revoked nor expired.
iduuiddefault generated (UUIDv7)- The session's ID. Appears in access tokens as
sidand in audit events. - Primary key
user_iduuid- Whose session this is.
- Foreign key to
identity.users(id), delete cascades token_hashtext- SHA-256 of the cookie's token. The token itself is never stored, so a database leak cannot be used to sign in.
- Unique. Exactly 64 lower-case hex characters
created_attimestamptzdefault now()- When the user signed in.
expires_attimestamptz- When the session stops working: 7 days after
created_at. - Later than
created_at revoked_attimestamptzcan be empty- Set when the user signs out or their sessions are revoked after a password reset. Empty means still active.
- Not earlier than
created_at
identity.signing_keys
The keys that sign access tokens. Usually one row; two for a few minutes during a rotation.
kidtext- The key's name, for example
k2026-11. Written into every token so a service knows which public key to use. - Primary key. 1 to 64 characters
public_jwkjsonb- The public half, in the format served by
GET /jwks. - Must contain
kty,crv,x,yand must not containd private_key_encryptedtext- The private half, encrypted with a key held only in the service's environment. Never leaves the service.
created_attimestamptzdefault now()- When the key was created.
retired_attimestamptzcan be empty- When the key stopped signing new tokens. Empty means it is the active key.
- Not earlier than
created_at
identity.audit_events
An append-only record of what happened. Every service has this table from the service template; these are the events login writes.
iduuiddefault generated (UUIDv7)- The event's ID.
- Primary key
actor_iduuidcan be empty- The user who acted. Empty when sign-in failed before a user was known.
actor_typetext- What kind of caller acted.
- One of
user,api_key,service,system actiontext- What happened.
- For login:
auth.signup,auth.signin,auth.signout,auth.signin_failed,auth.sessions_revoked target_typetextcan be empty- The kind of thing acted on, for example
session. target_iduuidcan be empty- Its ID.
metadatajsonbdefault '{}'- Small extra facts about the event.
- Allow-listed keys only:
reason,mode,count. Never tokens, codes, passwords or email addresses request_idtextcan be empty- The request that caused it, to trace across services.
created_attimestamptzdefault now()- When it happened.
The service template also gives Identity idempotency_keys and outbound_events. Login does not use them: its endpoints are redirects and reads, and the only event Identity announces (identity.user.deleted) belongs to Account management.
Data model level: business rules the service guarantees
- A user exists only for a verified email. Unverified sign-ins create nothing.
- One person is one user: matched by Cognito's permanent ID, never by email alone.
- A session is valid only if it is not revoked and not past
expires_at. Both are checked on every use. - Session lifetime is 7 days and is not extended by use (sliding expiry arrives in version 2).
- Access tokens live 5 minutes and are never stored. Signing out stops new tokens at once; an already-issued token works for at most 5 more minutes.
- Only hashes of session tokens are stored. Cognito's tokens and the user's password are never stored at all.
- After a password reset, all of that user's older sessions are revoked at the next sign-in.
- Unknown, expired and revoked sessions all get the same
401, so an attacker learns nothing. - Every sign-up, sign-in, sign-out and failed sign-in writes an audit event in the same transaction as the change.
What is deliberately not stored
- Passwords: they live only in AWS Cognito.
- Cognito's tokens: used once at the callback and discarded.
- The session token itself: only its hash.
- Access tokens: they are verified by signature, never looked up.