Tearleads

user_two_factor API Postgres table

A user's authenticator (TOTP, RFC 6238) for two-factor sign-in.

Declared in packages/api-shared/src/schema/twoFactor.ts

Description

Login is a signature by the identity key; this row adds a second factor the key alone cannot answer. It is server-enforced product state, outside the signed access plane.

Columns

  • user_iduuid
    • primary key
    • not null
    • references users (id)

    The user; one authenticator per user.

  • secret_ciphertexttext
    • not null

    The TOTP secret, sealed with AES-256-GCM under a key the API derives from TWO_FACTOR_SECRET_KEY and bound to userId, so a database read alone cannot produce codes.

  • enabled_attimestamp
    • nullable

    When a code from the secret was first confirmed and sign-in began asking for one. Null while setup is pending; a pending row is replaced by the next setup and ignored at sign-in.

  • last_used_stepbigint
    • nullable

    The 30-second time step of the last accepted code. A code from that step or an earlier one is refused, so an observed code cannot be replayed.

  • failed_attemptsinteger
    • not null
    • default 0

    Consecutive wrong codes and the lockout they started. Only the key holder reaches code checks.

  • locked_untiltimestamp
    • nullable

    Consecutive wrong codes and the lockout they started. Only the key holder reaches code checks.

  • created_attimestamp
    • not null
    • default now()

    Server-side row timestamps.

  • updated_attimestamp
    • not null
    • default now()

    Server-side row timestamps.

Keys and constraints

  • Foreign key(user_id)references users (id)

    on delete cascade