feat(auth): add WebAuthn MFA credentials (#1628)

* feat(auth): add WebAuthn MFA credentials

* fix(auth): harden WebAuthn MFA review paths

* fix(auth): polish WebAuthn error handling

* fix(auth): handle duplicate WebAuthn credential races

* fix(auth): permit WebAuthn credential params

* fix(auth): trim WebAuthn registration controller cleanup

* fix(auth): tighten WebAuthn MFA handling

* fix(auth): pin WebAuthn relying party config
This commit is contained in:
ghost
2026-05-03 14:13:28 -06:00
committed by GitHub
parent faf31b9c91
commit 911aa34ba9
29 changed files with 1117 additions and 10 deletions

View File

@@ -0,0 +1,31 @@
# frozen_string_literal: true
module WebauthnRelyingParty
extend ActiveSupport::Concern
private
def webauthn_relying_party
webauthn_config = Rails.application.config.x.webauthn
WebAuthn::RelyingParty.new(
name: "Sure",
id: webauthn_config.rp_id,
allowed_origins: webauthn_config.allowed_origins,
# Accept consumer passkeys/security keys without attesting device vendor
# identity; this keeps MFA registration broad for self-hosted users.
verify_attestation_statement: false
)
end
def webauthn_credential_payload
payload = params.require(:credential)
payload = JSON.parse(payload) if payload.is_a?(String)
payload = payload.to_unsafe_h if payload.respond_to?(:to_unsafe_h)
raise ActionController::BadRequest, "credential must be an object" unless payload.is_a?(Hash)
payload
rescue JSON::ParserError, TypeError, ArgumentError
raise ActionController::BadRequest, "invalid credential payload"
end
end