Skip to content

Data Protection

  • At rest: Railway encrypts volumes, backups, point-in-time recovery, buckets, and variables (AES-256). The API does not encrypt columns itself.
  • Column types: PII is stored as ordinary TEXT (user name and email, invite email, surety and contractor details, org domain), TEXT[] (surety.attorneys, surety.notes (#516), contractor_account.notes), and JSONB (the audit log’s before / after snapshots).
  • Uniqueness: emails are unique case-insensitively (uniq_auth_user_email on lower(email)), and lookups compare lower(email). Org domains are UNIQUE (domain) and NULL when unset.
  • Passwords: bcrypt, cost 12 (authn.HashPassword / authn.ValidatePassword in internal/authn/hash.go).
  • OTP codes: only an HMAC-SHA256 of the code is stored (auth.otp.code_hash), keyed with AUTH_OTP_SECRET (AuthConfig.OTPSecret) and compared in constant time.

Migrations 00028–00030 decrypted every column in place: 00028 added plaintext twins, 00029 filled them, and 00030 swapped them in and dropped the encrypted domain. 00029 was a Go migration; #504 replaced it with an empty SQL placeholder (00029_auth_decrypt_fields.sql) whose Down raises migration 00029 is irreversible, so migrate down cannot cross it.