mirror of
https://github.com/we-promise/sure.git
synced 2026-09-03 05:41:18 +00:00
* feat(auth): sign in with a passkey, without a password Passkeys could only ever replace the TOTP code: registration required 2FA to already be on, and the WebAuthn ceremony was reachable only after User.authenticate_by had succeeded. A registered passkey can now complete sign-in on its own, from the login page. The ceremony requests userVerification: "required", so the authenticator has to confirm the person as well as the device. That makes a lone passkey two independent factors, the same bar as the password plus TOTP flow it replaces, which is why this path deliberately skips the TOTP step. A credential that can only prove presence is rejected here and still works as a second factor. Sign-in is usernameless: no email is submitted, because the browser returns the account handle with the assertion. Nothing on this path can be probed to learn whether an account exists. Registration now asks for a discoverable credential with residentKey: "preferred" so the key is offered by the picker, while authenticators without a free resident-key slot still register as a second factor. Where conditional mediation is available, saved passkeys appear in the email field's autofill menu; everywhere else the button covers it. The automatic challenge request that conditional mediation makes on every page load gets its own looser Rack::Attack budget, so ordinary page views can no longer exhaust the limit that protects the MFA endpoints. Set AUTH_PASSKEY_LOGIN_ENABLED=false to keep passkeys as a second factor only. Passkey sign-in follows the same policy as local login, so it stays closed to regular users when AUTH_LOCAL_LOGIN_ENABLED is false. * refactor(auth): group the passkey button with the other sign-in methods It sat directly under the password fields, so the forgot-password link split it from the identical SSO buttons. It is an alternative to the credential form rather than part of it. * fix(auth): close the passkey challenge races and document the upgrade Three review passes converged on the conditional-mediation flow. The AbortController was created after `isConditionalMediationAvailable()` resolved, so a button click or a Turbo disconnect landing in that window found nothing to abort: the conditional task carried on, re-minted the challenge, and the assertion the user was about to produce verified against a challenge the server had already replaced. It is created before the first await now, and held in a local, because `abortConditionalMediation()` nulls the field. Checking that one signal after each await covers both triggers, so no separate connected flag is needed. The same symptom had a second cause nobody flagged: `authenticate()` was not re-entrant. A double-click minted a fresh challenge under an open authenticator prompt and rejected a perfectly valid passkey, with no race window at all — and it was live on the MFA step-up too, which shares the method. The conditional catch was silent for every failure, including a rejected assertion the user had deliberately chosen from the autofill menu. Splitting the try draws the line where it belongs: silence before the user has been asked anything, feedback once they have picked a passkey. Filtering on `error.name` cannot draw it, since `fetchOptions` and `verifyCredential` both raise a plain Error. Also documents the upgrade: passwordless is on by default and applies to already-registered credentials, so a passkey added purely as a second factor can now sign its owner in alone. Nothing in the schema marks a credential discoverable — the authenticator decides — and the opt-out is instance-wide. The invitation test is a guard, not coverage for this change. The pending token lives in the Rack session and `complete_sign_in` reads it right after creating the session, so a `reset_session` dropped in between strands the invitee in their own family, silently and with every existing test still green. * fix(auth): cancel the in-flight conditional options request Aborting the conditional flow did not cancel its options request, because `fetchOptions` never received the signal. A click landing while that POST was in flight left it to finish, and its response could apply last. The challenge rides in the session cookie, so "the server wrote it" only counts if the Set-Cookie reaches the browser. Threading the signal means an aborted request's response is discarded, which closes the window without needing the server to hold two challenges open. Also drops the absolute claim about which existing credentials gain passwordless sign-in. `residentKey: "preferred"` is a request an authenticator may decline, and nothing records what it decided, so the honest statement is that password managers and platform authenticators generally store discoverable credentials rather than always.
77 lines
3.4 KiB
YAML
77 lines
3.4 KiB
YAML
default: &default
|
|
local_login:
|
|
# When false, local email/password login is disabled for all users unless
|
|
# AUTH_LOCAL_ADMIN_OVERRIDE_ENABLED is true and the user is a super admin.
|
|
enabled: <%= ENV.fetch("AUTH_LOCAL_LOGIN_ENABLED", "true") == "true" %>
|
|
|
|
# When true and local_login.enabled is false, allow super admins to use
|
|
# local login as an emergency override. Regular users remain SSO-only.
|
|
admin_override_enabled: <%= ENV.fetch("AUTH_LOCAL_ADMIN_OVERRIDE_ENABLED", "false") == "true" %>
|
|
|
|
passkey_login:
|
|
# When true, users with a registered passkey can sign in without a password
|
|
# (and without the TOTP step). User verification is always required for this
|
|
# path, so the passkey alone is two factors. Set to false to keep passkeys
|
|
# as a second factor only.
|
|
enabled: <%= ENV.fetch("AUTH_PASSKEY_LOGIN_ENABLED", "true") == "true" %>
|
|
|
|
jit:
|
|
# Controls behavior when a user signs in via SSO and no OIDC identity exists.
|
|
# - "create_and_link" (default): create a new user + family when no match exists
|
|
# - "link_only": require an existing user; block JIT creation
|
|
mode: <%= ENV.fetch("AUTH_JIT_MODE", "create_and_link") %>
|
|
|
|
# Optional comma-separated list of domains (e.g. "example.com,corp.com").
|
|
# When non-empty, JIT SSO account creation is only allowed for these domains.
|
|
# When empty, all domains are allowed (current behavior).
|
|
allowed_oidc_domains: <%= ENV.fetch("ALLOWED_OIDC_DOMAINS", "") %>
|
|
|
|
providers:
|
|
# Generic OpenID Connect provider (e.g., Keycloak, Authentik, other OIDC issuers).
|
|
# This maps to the existing :openid_connect OmniAuth strategy and keeps
|
|
# backwards-compatible behavior for self-hosted setups using OIDC_* env vars.
|
|
#
|
|
# For the default OIDC provider, use these ENV vars:
|
|
# OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, OIDC_REDIRECT_URI
|
|
#
|
|
# To add additional OIDC providers, add more entries with unique names and use
|
|
# provider-specific ENV vars with the pattern: OIDC_<UPPERCASE_NAME>_*
|
|
# Example for a provider named "keycloak":
|
|
# OIDC_KEYCLOAK_ISSUER, OIDC_KEYCLOAK_CLIENT_ID,
|
|
# OIDC_KEYCLOAK_CLIENT_SECRET, OIDC_KEYCLOAK_REDIRECT_URI
|
|
- id: "oidc"
|
|
strategy: "openid_connect"
|
|
name: "openid_connect"
|
|
label: <%= ENV.fetch("OIDC_BUTTON_LABEL", "") %>
|
|
icon: <%= ENV.fetch("OIDC_BUTTON_ICON", "key") %>
|
|
# Per-provider credentials (optional, falls back to global OIDC_* vars)
|
|
issuer: <%= ENV["OIDC_ISSUER"] %>
|
|
client_id: <%= ENV["OIDC_CLIENT_ID"] %>
|
|
client_secret: <%= ENV["OIDC_CLIENT_SECRET"] %>
|
|
redirect_uri: <%= ENV["OIDC_REDIRECT_URI"] %>
|
|
|
|
# Optional Google OAuth provider. Requires the omniauth-google-oauth2 gem
|
|
# and GOOGLE_OAUTH_CLIENT_ID / GOOGLE_OAUTH_CLIENT_SECRET env vars.
|
|
- id: "google"
|
|
strategy: "google_oauth2"
|
|
name: "google_oauth2"
|
|
label: <%= ENV.fetch("GOOGLE_BUTTON_LABEL", "Sign in with Google") %>
|
|
icon: <%= ENV.fetch("GOOGLE_BUTTON_ICON", "google") %>
|
|
|
|
# Optional GitHub OAuth provider. Requires the omniauth-github gem and
|
|
# GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET env vars.
|
|
- id: "github"
|
|
strategy: "github"
|
|
name: "github"
|
|
label: <%= ENV.fetch("GITHUB_BUTTON_LABEL", "Sign in with GitHub") %>
|
|
icon: <%= ENV.fetch("GITHUB_BUTTON_ICON", "github") %>
|
|
|
|
development:
|
|
<<: *default
|
|
|
|
test:
|
|
<<: *default
|
|
|
|
production:
|
|
<<: *default
|