Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Support RS256 algorithm for webauthn (#8385)

Martin Brennan5ad6dc01c146
diff --git a/lib/webauthn.rb b/lib/webauthn.rb
index d53eefe3635..c8656d8fa70 100644
--- a/lib/webauthn.rb
+++ b/lib/webauthn.rb
@@ -6,7 +6,10 @@ require 'webauthn/security_key_authentication_service'
module Webauthn
ACCEPTABLE_REGISTRATION_TYPE = "webauthn.create".freeze
ACCEPTABLE_AUTHENTICATION_TYPE = "webauthn.get".freeze
- SUPPORTED_ALGORITHMS = [-7].freeze
+
+ # -7 - ES256
+ # -257 - RS256 (Windows Hello supported alg.)
+ SUPPORTED_ALGORITHMS = [-7, -257].freeze
VALID_ATTESTATION_FORMATS = ['none', 'packed', 'fido-u2f'].freeze
class SecurityKeyError < StandardError; end
diff --git a/lib/webauthn/security_key_registration_service.rb b/lib/webauthn/security_key_registration_service.rb
index bea9e322f28..ff8544f1ac5 100644
--- a/lib/webauthn/security_key_registration_service.rb
+++ b/lib/webauthn/security_key_registration_service.rb
@@ -49,7 +49,7 @@ module Webauthn
# attribute of one of the items in options.pubKeyCredParams.
# https://w3c.github.io/webauthn/#table-attestedCredentialData
# See https://www.iana.org/assignments/cose/cose.xhtml#algorithms for supported algorithm
- # codes, -7 which Discourse uses is ECDSA w/ SHA-256
+ # codes.
credential_public_key, credential_public_key_bytes, credential_id = extract_public_key_and_credential_from_attestation(auth_data)
raise(UnsupportedPublicKeyAlgorithmError, I18n.t('webauthn.validation.unsupported_public_key_algorithm_error')) if ::Webauthn::SUPPORTED_ALGORITHMS.exclude?(credential_public_key.alg)
diff --git a/spec/lib/webauthn/security_key_registration_service_spec.rb b/spec/lib/webauthn/security_key_registration_service_spec.rb
index 17bc9ff1495..672ddac56e7 100644
--- a/spec/lib/webauthn/security_key_registration_service_spec.rb
+++ b/spec/lib/webauthn/security_key_registration_service_spec.rb
@@ -87,7 +87,7 @@ describe Webauthn::SecurityKeyRegistrationService do
before do
@original_supported_alg_value = Webauthn::SUPPORTED_ALGORITHMS
silence_warnings do
- Webauthn::SUPPORTED_ALGORITHMS = [-257]
+ Webauthn::SUPPORTED_ALGORITHMS = [-999]
end
end