Files
sure/app/models/webauthn_credential.rb
ghost 911aa34ba9 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
2026-05-03 22:13:28 +02:00

16 lines
513 B
Ruby

class WebauthnCredential < ApplicationRecord
belongs_to :user
before_validation :set_default_nickname
validates :nickname, presence: true, length: { maximum: 80 }
validates :credential_id, presence: true, uniqueness: true
validates :public_key, presence: true
validates :sign_count, numericality: { greater_than_or_equal_to: 0, only_integer: true }
private
def set_default_nickname
self.nickname = nickname.to_s.strip.presence || I18n.t("webauthn_credentials.default_name")
end
end