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>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 15:17:56 -05:00
1 parent a6bfe922be
commit 14316bb60f
41 files changed
+600 -45

No files matched your search

+3 -2
View File
@@ -4,13 +4,14 @@ require "rails/test_help"
require "webmock/minitest"
WebMock.disable_net_connect!(allow_localhost: true)
Dir[File.expand_path("support/**/*.rb", __dir__)].each { require _1 }
PwnedPasswords.checker = ->(password) { password == "breached-password-1" } # no network in tests
module ActiveSupport
class TestCase
parallelize(workers: :number_of_processors)
def create_user(email = "user#{SecureRandom.hex(3)}@example.com", admin: false)
User.create!(email_address: email, password: "password123", name: email.split("@").first, admin: admin)
User.create!(email_address: email, password: "test-password-123", name: email.split("@").first, admin: admin)
end
def create_aircraft(owner: nil, pilot: nil, **attrs)
@@ -33,7 +34,7 @@ end
class ActionDispatch::IntegrationTest
def sign_in(user)
post session_path, params: { email_address: user.email_address, password: "password123" }
post session_path, params: { email_address: user.email_address, password: "test-password-123" }
follow_redirect!
end
end