Skip to content

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

WebAuthn verification 1st step

Klaus Zanders9f20c8bb3bb5
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb b/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
index 9a8c54ee6ac..b18065afef9 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
@@ -90,6 +90,10 @@ module TwoFactorAuthentication
strategy_class.supported_channels & supported_channels
end
+ def input_based?
+ true
+ end
+
private
def self.manager
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication/device/webauthn.rb b/modules/two_factor_authentication/app/models/two_factor_authentication/device/webauthn.rb
index 503ba4bf63a..531ae51acdf 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication/device/webauthn.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/device/webauthn.rb
@@ -31,8 +31,12 @@ module TwoFactorAuthentication
)
end
- def request_2fa_identifier(channel)
- # NOOP
+ def request_2fa_identifier(_channel)
+ identifier
+ end
+
+ def input_based?
+ false
end
end
end
diff --git a/modules/two_factor_authentication/app/views/two_factor_authentication/authentication/request_otp.html.erb b/modules/two_factor_authentication/app/views/two_factor_authentication/authentication/request_otp.html.erb
index afef8a19b63..d1ff47bdd28 100644
--- a/modules/two_factor_authentication/app/views/two_factor_authentication/authentication/request_otp.html.erb
+++ b/modules/two_factor_authentication/app/views/two_factor_authentication/authentication/request_otp.html.erb
@@ -1,7 +1,6 @@
<% resend_supported = @strategy.mobile_token? %>
<% has_other_devices = @active_devices.count > 1 %>
<% has_backup_codes = @authenticated_user.otp_backup_codes.exists? %>
-
<% html_title t(:field_otp) %>
<% breadcrumb_paths(t(:field_otp)) %>
<div id="login-form"
@@ -13,17 +12,22 @@
{ action: :confirm_otp },
id: 'submit_otp',
autocomplete: "off") do %>
+ <%= back_url_hidden_field_tag %>
<h2><%= t 'two_factor_authentication.label_two_factor_authentication' %></h2>
<% identifier = @used_device.request_2fa_identifier(@strategy.channel) %>
- <p><%= raw I18n.t('two_factor_authentication.devices.request_2fa', device_name: identifier) %></p>
- <hr class="form--separator">
- <%= back_url_hidden_field_tag %>
- <div class="form--field -wide-label">
- <%= styled_label_tag 'otp', t(:field_otp) %>
- <div class="form--field-container">
- <%= styled_text_field_tag 'otp', nil, autocomplete: 'off', size: 6, maxlength: 6, tabindex: 1, autofocus: true %>
+ <% if @used_device.input_based? %>
+ <p><%= raw I18n.t('two_factor_authentication.devices.2fa_from_input', device_name: identifier) %></p>
+ <hr class="form--separator">
+ <div class="form--field -wide-label">
+ <%= styled_label_tag 'otp', t(:field_otp) %>
+ <div class="form--field-container">
+ <%= styled_text_field_tag 'otp', nil, autocomplete: 'off', size: 6, maxlength: 6, tabindex: 1, autofocus: true %>
+ </div>
</div>
- </div>
+ <% else %>
+ <p><%= raw I18n.t('two_factor_authentication.devices.2fa_from_webauthn', device_name: identifier) %></p>
+ <hr class="form--separator">
+ <% end %>
<% if remember_2fa_enabled? %>
<div class="form--field -wide-label">
<label class="form--label-with-check-box -no-ellipsis">
@@ -66,7 +70,6 @@
<%= radio_button_tag 'use_channel', channel, default_channel == channel %>
<label for="channel_<%= channel %>"><%= t("button_otp_by_#{channel}") %></label>
<% end %>
-
</div>
<input type="submit" value="<%= t(:button_resend_otp_form) %>" id="submit_resend_form" class="button -highlight"/>
<% end %>
@@ -90,9 +93,9 @@
<ul>
<li>
<%= link_to(t('two_factor_authentication.login.enter_backup_code_title'), { action: :enter_backup_code }) %>
- </a>
- </li>
- </ul>
- <% end %>
- </div>
+ </a>
+ </li>
+ </ul>
+ <% end %>
+</div>
</div>
diff --git a/modules/two_factor_authentication/config/locales/en.yml b/modules/two_factor_authentication/config/locales/en.yml
index f2b0396146c..51edc1ab798 100644
--- a/modules/two_factor_authentication/config/locales/en.yml
+++ b/modules/two_factor_authentication/config/locales/en.yml
@@ -118,7 +118,8 @@ en:
failed_to_delete: 'Failed to delete 2FA device.'
is_default_cannot_delete: 'The device is marked as default and cannot be deleted due to an active security policy. Mark another device as default before deleting.'
not_existing: 'No 2FA device has been registered for your account.'
- request_2fa: Please enter the code from your %{device_name} to verify your identity.
+ 2fa_from_input: Please enter the code from your <strong>%{device_name}</strong> to verify your identity.
+ 2fa_from_webauthn: Please provide the WebAuthn device <strong>%{device_name}</strong>. If it is USB based make sure to plug it in and touch it.
webauthn:
title: 'WebAuthn'
description: Use Web Authentication to register a FIDO2 device (like a YubiKey) or the secure enclave of your mobile device as a second factor.