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

Start implementation for authentication

Klaus Zanders764424bf00ab
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 eca00e0dad7..503ba4bf63a 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
@@ -24,5 +24,15 @@ module TwoFactorAuthentication
exclude: TwoFactorAuthentication::Device::Webauthn.where(user:).pluck(:webauthn_external_id)
)
end
+
+ def options_for_get
+ @options_for_get ||= WebAuthn::Credential.options_for_get(
+ allow: webauthn_external_id # TODO: Maybe also allow all other tokens? Let's see
+ )
+ end
+
+ def request_2fa_identifier(channel)
+ # NOOP
+ end
end
end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/webauthn.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/webauthn.rb
index 5763ffb6229..c1f59156c5c 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/webauthn.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/webauthn.rb
@@ -3,6 +3,33 @@ require 'webauthn'
module OpenProject::TwoFactorAuthentication
module TokenStrategy
class Webauthn < Base
+ def verify(webauthn_params)
+ webauthn_credential = WebAuthn::Credential.from_get(webauthn_params)
+
+ # TODO: Device finding can happen by the provided ID
+
+ # TODO: Access session
+ authentication_challenge = "foo"
+
+ # This will raise WebAuthn::Error
+ webauthn_credential.verify(
+ authentication_challenge,
+ public_key: device.webauthn_public_key,
+ sign_count: device.webauthn_sign_count
+ )
+
+ device.update!(webauthn_sign_count: webauthn_credential.sign_count)
+ true
+ end
+
+ def transmit_success_message
+ nil
+ end
+
+ def self.mobile_token?
+ false
+ end
+
def self.supported_channels
[:webauthn]
end
@@ -14,6 +41,13 @@ module OpenProject::TwoFactorAuthentication
def self.identifier
:webauthn
end
+
+ private
+
+ def send_webauthn
+ Rails.logger.info { "[2FA] WebAuthn in progress for #{user.login}" }
+ # Nothing to do here
+ end
end
end
end