FEATURE: Support RS256 algorithm for webauthn (#8385)

* Add support for RS256 webauthn algorithm (-257)
This commit is contained in:
Martin Brennan 2019-11-21 15:45:36 +10:00 committed by GitHub
parent b57e108e84
commit 5ad6dc01c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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