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

Add WebAuthn model and some text for the UI

Klaus Zanders397c6912e721
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
new file mode 100644
index 00000000000..a7f51cf9e7e
--- /dev/null
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/device/webauthn.rb
@@ -0,0 +1,21 @@
+module TwoFactorAuthentication
+ class Device::Webauthn < Device
+ validates :webauthn_external_id, presence: true, uniqueness: true
+ validates :webauthn_public_key, presence: true
+
+ # Check allowed channels
+ def self.supported_channels
+ %i(webauthn)
+ end
+
+ def self.device_type
+ :webauthn
+ end
+
+ # Set default channel
+ after_initialize do
+ self.channel ||= :webauthn
+ end
+ validates_inclusion_of :channel, in: supported_channels
+ end
+end
diff --git a/modules/two_factor_authentication/config/locales/en.yml b/modules/two_factor_authentication/config/locales/en.yml
index 41d7da19bec..f2b0396146c 100644
--- a/modules/two_factor_authentication/config/locales/en.yml
+++ b/modules/two_factor_authentication/config/locales/en.yml
@@ -119,6 +119,9 @@ en:
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.
+ 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.
totp:
title: 'Use your app-based authenticator'
provisioning_uri: 'Provisioning URI'
@@ -151,6 +154,7 @@ en:
totp: 'Authenticator application'
sns: 'Amazon SNS'
resdt: 'SMS Rest API'
+ webauthn: 'WebAuthn'
mobile_transmit_notification: "A one-time password has been sent to your cell phone."
label_two_factor_authentication: 'Two-factor authentication'
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb
index fbee9242e14..558adf26bcb 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb
@@ -113,8 +113,8 @@ module OpenProject::TwoFactorAuthentication
def merge_with_settings!(config)
config['active_strategies'] ||= []
- # Always enable totp if nothing is enabled
- config['active_strategies'] << :totp if add_default_strategy?(config)
+ # Always enable webauthn and totp if nothing is enabled
+ config['active_strategies'] += %i[totp webauthn] if add_default_strategy?(config)
end
def add_default_strategy?(config)