11# frozen_string_literal: true
22
3- # rubocop:disable Metrics/ModuleLength
43module Devise
54 module Webauthn
65 module CredentialsHelper
@@ -59,75 +58,6 @@ def login_with_security_key_button(text = nil, resource:, button_classes: nil, f
5958 end
6059 end
6160
62- def create_passkey_options ( resource )
63- @create_passkey_options ||= begin
64- options = WebAuthn ::Credential . options_for_create (
65- user : {
66- id : resource . webauthn_id ,
67- name : resource_human_palatable_identifier
68- } ,
69- exclude : resource . passkeys . pluck ( :external_id ) ,
70- authenticator_selection : {
71- resident_key : "required" ,
72- user_verification : "required"
73- }
74- )
75-
76- # Store challenge in session for later verification
77- session [ :webauthn_challenge ] = options . challenge
78-
79- options
80- end
81- end
82-
83- def passkey_authentication_options
84- @passkey_authentication_options ||= begin
85- options = WebAuthn ::Credential . options_for_get (
86- user_verification : "required"
87- )
88-
89- # Store challenge in session for later verification
90- session [ :authentication_challenge ] = options . challenge
91-
92- options
93- end
94- end
95-
96- def create_security_key_options ( resource )
97- @create_security_key_options ||= begin
98- options = WebAuthn ::Credential . options_for_create (
99- user : {
100- id : resource . webauthn_id ,
101- name : resource_human_palatable_identifier
102- } ,
103- exclude : resource . webauthn_credentials . pluck ( :external_id ) ,
104- authenticator_selection : {
105- resident_key : "discouraged" ,
106- user_verification : "discouraged"
107- }
108- )
109-
110- # Store challenge in session for later verification
111- session [ :webauthn_challenge ] = options . challenge
112-
113- options
114- end
115- end
116-
117- def security_key_authentication_options ( resource )
118- @security_key_authentication_options ||= begin
119- options = WebAuthn ::Credential . options_for_get (
120- allow : resource . webauthn_credentials . pluck ( :external_id ) ,
121- user_verification : "discouraged"
122- )
123-
124- # Store challenge in session for later verification
125- session [ :two_factor_authentication_challenge ] = options . challenge
126-
127- options
128- end
129- end
130-
13161 private
13262
13363 def resource_human_palatable_identifier
@@ -139,4 +69,3 @@ def resource_human_palatable_identifier
13969 end
14070 end
14171end
142- # rubocop:enable Metrics/ModuleLength
0 commit comments