feat(v1.1.8): app_users table + repo (migration 0026)

Per-app end-user table for the v1.1.8 users::* SDK. Distinct from
admin_users (control-plane operators) — same Argon2id password hash
shape but everything else (uniqueness scope, ownership, lifecycle)
independent.

- Uniqueness on (app_id, lower(email)) — case-insensitive within an
  app; same email may exist across two apps.
- AppUserRepository trait + Postgres impl; every method takes app_id
  explicitly so cross-app reads are unmistakable at the call site
  (matches v1.1.3 cross-app discipline).
- Public AppUserRow never includes the password hash; the credentials
  shape is its own struct returned only by the login lookup.
- Cursor-based list keyed on (created_at, id).
- Reserved a timing-flat dummy Argon2id PHC constant in auth.rs for
  the upcoming login path so the bad-email and good-email branches
  share wall-clock cost.
- Added AppUserId + InvitationId id types in shared::ids.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-05 23:15:47 +02:00
parent 6ef9f436c1
commit 97546e2eb2
6 changed files with 446 additions and 1 deletions

View File

@@ -25,6 +25,16 @@ use sha2::{Digest, Sha256};
#[error("invalid Argon2id PHC hash")]
pub struct InvalidPasswordHash;
/// Real Argon2id PHC string used by the timing-flat login path: on a
/// bad-email lookup the login routine still runs `verify_password`
/// against this hash so the wall-clock cost matches the good-email
/// branch. The plaintext that produced this hash is irrelevant —
/// `verify_password` will return false for any input the caller could
/// realistically present, and the surrounding code drops the result.
/// Reusing the existing admin-auth login pattern from `auth_api.rs`.
pub const TIMING_FLAT_DUMMY_HASH: &str =
"$argon2id$v=19$m=19456,t=2,p=1$dGltaW5nLWZsYXR0ZW4$Ux6dgPqgX1Mhg5fRgIeKZF3MWdYqJplKEz/cKLcSdks";
/// Hash a raw password into an Argon2id PHC-formatted string suitable
/// for `admin_users.password_hash`. The output already encodes the salt
/// and parameters; nothing else needs to be persisted alongside it.