Files
simple-aircraft-manager-rails/db/migrate/20261108050000_add_sign_in_hardening.rb
rickyandClaude Opus 5.5 14316bb60f Sign-in hardening: lockout, stronger passwords, authenticator codes
- 10 failed sign-ins in a row (password, authenticator code, or password
  at signing) lock an account for 15 minutes from any address; the user
  is emailed; admins can unlock. Same message as a wrong password.
- Passwords: at least 12 characters (max 72), refused if found in Have I
  Been Pwned (k-anonymity range API; fails open; PWNED_PASSWORDS_CHECK=false)
- Optional TOTP (authenticator app) with 10 recovery codes for password
  and emailed-link sign-in, and at signing (auth method password_totp);
  codes accepted once; admins can reset; SSO sign-in unaffected
- Demo/test passwords updated; guide, README and procedures document

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 15:17:56 -05:00

13 lines
579 B
Ruby

class AddSignInHardening < ActiveRecord::Migration[8.1]
def change
# Account lockout after repeated failed sign-ins (from any address).
add_column :users, :failed_sign_ins, :integer, null: false, default: 0
add_column :users, :locked_until, :datetime
# Authenticator app (TOTP) as a second factor for password sign-in.
add_column :users, :otp_secret, :text
add_column :users, :otp_enabled_at, :datetime
add_column :users, :otp_last_used_at, :integer # last accepted time step (no replays)
add_column :users, :otp_recovery_codes, :json
end
end