OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Enable WebAuthn in the forced registration controller
Klaus Zanders3d1a49720fff
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rbindex 7d025617294..bedf5f1dcf6 100644--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb@@ -21,14 +21,30 @@ module ::TwoFactorAuthentication### Register the device and let the user confirm- def register+ def register # rubocop:disable Metrics/AbcSize@device_type = params[:key].to_sym@device = new_device_type! @device_type- @device.attributes = new_device_params+ needs_confirmation = true++ if @device_type == :webauthn+ if verify_webauthn_credential+ @device.attributes = new_webauthn_device_params+ needs_confirmation = false+ end+ else+ @device.attributes = new_device_params+ end+if @device.saveRails.logger.info "User ##{target_user.id} forced to register a new (unconfirmed) device #{@device_type}."- redirect_to action: :confirm, device_id: @device.id+ if needs_confirmation+ redirect_to action: :confirm, device_id: @device.id+ else+ flash[:notice] = t('two_factor_authentication.devices.registration_complete')+ @device.confirm_registration_and_save+ redirect_to registration_success_path+ endelseRails.logger.warn { "User ##{target_user.id} forced to register failed for #{@device_type}." }render 'two_factor_authentication/two_factor_devices/new'diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rbindex fa9b5fce63c..f5506c3ab0d 100644--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb@@ -30,7 +30,7 @@ module ::TwoFactorAuthentication### Register the device and let the user confirm- def register+ def register # rubocop:disable Metrics/AbcSize@device_type = params[:key].to_sym@device = new_device_type! @device_typediff --git a/modules/two_factor_authentication/config/routes.rb b/modules/two_factor_authentication/config/routes.rbindex d28379b9bd8..1182534b0ee 100644--- a/modules/two_factor_authentication/config/routes.rb+++ b/modules/two_factor_authentication/config/routes.rb@@ -14,11 +14,14 @@ Rails.application.routes.draw doendscope 'two_factor_authentication' do # Avoids adding the namespace prefix- scope 'device_registration',- controller: 'two_factor_authentication/forced_registration/two_factor_devices' do+ # forced registration+ scope 'device_registration', controller: 'two_factor_authentication/forced_registration/two_factor_devices' doget :new, action: :new, as: 'new_forced_2fa_device'post :register, action: :register, as: 'register_forced_2fa_device'match '/:device_id/confirm', action: :confirm, via: %i[get post], as: 'confirm_forced_2fa_device'++ # Request a challenge for WebAuthn+ get :webauthn_challengeendend