Module: Warden::WebAuthn::RegistrationHelpers
- Defined in:
- lib/warden/webauthn/registration_helpers.rb
Overview
Helper methods to bootstrap registration challenges for implementors
Instance Method Summary collapse
- #authenticator_selection_options ⇒ Object
- #delete_registration_challenge ⇒ Object
- #generate_registration_options(relying_party:, user_details:, exclude: [], options: {}) ⇒ Object
- #parsed_credential ⇒ Object
- #raw_credential ⇒ Object
- #raw_credential_key ⇒ Object
- #registration_challenge ⇒ Object
- #registration_challenge_key ⇒ Object
- #store_challenge_in_session(options_for_registration:) ⇒ Object
- #verify_registration(relying_party:) ⇒ Object
Instance Method Details
#authenticator_selection_options ⇒ Object
51 52 53 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 51 def { resident_key: "required", user_verification: "required" } end |
#delete_registration_challenge ⇒ Object
31 32 33 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 31 def delete_registration_challenge session.delete(registration_challenge_key) end |
#generate_registration_options(relying_party:, user_details:, exclude: [], options: {}) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 7 def (relying_party:, user_details:, exclude: [], options: {}) .(**{ user: user_details, exclude: exclude, authenticator_selection: }.merge()) end |
#parsed_credential ⇒ Object
35 36 37 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 35 def parsed_credential JSON.parse(raw_credential) end |
#raw_credential ⇒ Object
39 40 41 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 39 def raw_credential params[raw_credential_key] end |
#raw_credential_key ⇒ Object
43 44 45 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 43 def raw_credential_key "credential" end |
#registration_challenge ⇒ Object
27 28 29 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 27 def registration_challenge session[registration_challenge_key] end |
#registration_challenge_key ⇒ Object
47 48 49 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 47 def registration_challenge_key "current_webauthn_registration_challenge" end |
#store_challenge_in_session(options_for_registration:) ⇒ Object
15 16 17 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 15 def store_challenge_in_session(options_for_registration:) session[registration_challenge_key] = .challenge end |
#verify_registration(relying_party:) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/warden/webauthn/registration_helpers.rb', line 19 def verify_registration(relying_party:) .verify_registration( parsed_credential, registration_challenge, user_verification: true ) ensure delete_registration_challenge end |