mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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:
1 parent
a6bfe922be
commit
14316bb60f
41 files changed
+600
-45
No files matched your search
@@ -0,0 +1,9 @@
|
||||
<% content_for :title, "Recovery codes" %>
|
||||
<section class="card card-body mx-auto max-w-md space-y-4">
|
||||
<h1 class="text-2xl font-bold">Save your recovery codes</h1>
|
||||
<p class="text-sm text-slate-600">Two-factor is on. If you lose your phone, each of these codes signs you in once in place of an authenticator code. Print them or keep them in a password manager: they won't be shown again.</p>
|
||||
<ul class="grid grid-cols-2 gap-2 rounded-md bg-slate-50 p-4 font-mono text-sm ring-1 ring-slate-200">
|
||||
<% @codes.each do |c| %><li><%= c %></li><% end %>
|
||||
</ul>
|
||||
<%= link_to "Done", back_path, class: "btn-primary self-start" %>
|
||||
</section>
|
||||
@@ -0,0 +1,17 @@
|
||||
<% content_for :title, "Set up two-factor" %>
|
||||
<section class="card card-body mx-auto max-w-md space-y-4">
|
||||
<h1 class="text-2xl font-bold">Set up an authenticator app</h1>
|
||||
<p class="text-sm text-slate-600">After your password (or an emailed sign-in link) you'll also enter a 6-digit code from an app on your phone, so a stolen password alone can't get in. Any authenticator app works: Google Authenticator, Microsoft Authenticator, 1Password, Authy…</p>
|
||||
<ol class="list-decimal space-y-3 pl-5 text-sm">
|
||||
<li>In the app, add an account and scan this code:
|
||||
<div class="mt-2 inline-block rounded bg-white p-2"><%= image_tag @qr_data_uri, alt: "QR code for your authenticator app", class: "h-48 w-48" %></div>
|
||||
<p class="mt-1 text-xs text-slate-500">Can't scan it? Enter this key instead: <code class="break-all"><%= @secret.scan(/.{4}/).join(" ") %></code></p></li>
|
||||
<li>Enter the code the app shows:
|
||||
<%= form_with url: two_factor_path, class: "mt-2 flex flex-wrap items-end gap-2" do |f| %>
|
||||
<%= hidden_field_tag :return_to, params[:return_to] %>
|
||||
<%= f.text_field :code, required: true, autocomplete: "one-time-code", inputmode: "numeric", maxlength: 7, class: "input w-32 text-lg tracking-widest", "aria-label": "Code" %>
|
||||
<%= f.submit "Turn on", class: "btn-primary" %>
|
||||
<% end %></li>
|
||||
</ol>
|
||||
<p class="text-sm"><%= link_to "Not now", back_path, class: "link" %></p>
|
||||
</section>
|
||||
Reference in new issue
Block a user