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.rbindex d53eefe3635..c8656d8fa70 100644--- a/lib/webauthn.rb+++ b/lib/webauthn.rb@@ -6,7 +6,10 @@ require 'webauthn/security_key_authentication_service'module WebauthnACCEPTABLE_REGISTRATION_TYPE = "webauthn.create".freezeACCEPTABLE_AUTHENTICATION_TYPE = "webauthn.get".freeze- SUPPORTED_ALGORITHMS = [-7].freeze++ # -7 - ES256+ # -257 - RS256 (Windows Hello supported alg.)+ SUPPORTED_ALGORITHMS = [-7, -257].freezeVALID_ATTESTATION_FORMATS = ['none', 'packed', 'fido-u2f'].freezeclass SecurityKeyError < StandardError; enddiff --git a/lib/webauthn/security_key_registration_service.rb b/lib/webauthn/security_key_registration_service.rbindex 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.rbindex 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 dobefore do@original_supported_alg_value = Webauthn::SUPPORTED_ALGORITHMSsilence_warnings do- Webauthn::SUPPORTED_ALGORITHMS = [-257]+ Webauthn::SUPPORTED_ALGORITHMS = [-999]endend