diff --git a/.circleci/config.yml b/.circleci/config.yml index beac7cf..63eeef6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -36,30 +36,6 @@ jobs: bundle install bundle exec rake - "ruby-2-7": - docker: - - image: ruby:2.7 - steps: - - checkout - - run: - name: Run the default task - command: | - gem install bundler - bundle install - bundle exec rake - - "ruby-2-6": - docker: - - image: ruby:2.6 - steps: - - checkout - - run: - name: Run the default task - command: | - gem install bundler - bundle install - bundle exec rake - workflows: version: 2 @@ -67,6 +43,4 @@ workflows: jobs: - "ruby-3-2" - "ruby-3-1" - - "ruby-3-0" - - "ruby-2-6" - - "ruby-2-7" \ No newline at end of file + - "ruby-3-0" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index ded76e3..ae22c4d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - warden-webauthn (0.2.1) + warden-webauthn (0.3.1) warden webauthn (>= 3) diff --git a/lib/warden/webauthn/strategy_helpers.rb b/lib/warden/webauthn/strategy_helpers.rb index 57a22e5..24b1b1c 100644 --- a/lib/warden/webauthn/strategy_helpers.rb +++ b/lib/warden/webauthn/strategy_helpers.rb @@ -11,9 +11,10 @@ module StrategyHelpers class NoStoredCredentialFound < StandardError; end # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize def verify_authentication_and_find_stored_credential _, stored_credential = relying_party.verify_authentication( - parsed_credential, authentication_challenge, user_verification: true + parsed_credential, authentication_challenge, user_verification: user_verification_flag ) do |webauthn_credential| x = credential_finder.find_with_credential_id(Base64.strict_encode64(webauthn_credential.raw_id)) raise NoStoredCredentialFound if x.nil? @@ -33,6 +34,11 @@ def verify_authentication_and_find_stored_credential delete_authentication_challenge end # rubocop:enable Metrics/MethodLength + # rubocop:enable Metrics/AbcSize + + def user_verification_flag + true + end def relying_party env[relying_party_key] diff --git a/lib/warden/webauthn/version.rb b/lib/warden/webauthn/version.rb index 4e230f1..ad44326 100644 --- a/lib/warden/webauthn/version.rb +++ b/lib/warden/webauthn/version.rb @@ -2,6 +2,6 @@ module Warden module WebAuthn - VERSION = "0.3.0" + VERSION = "0.3.1" end end diff --git a/test/warden/test_strategy_helpers.rb b/test/warden/test_strategy_helpers.rb index d9aabbe..78d0639 100644 --- a/test/warden/test_strategy_helpers.rb +++ b/test/warden/test_strategy_helpers.rb @@ -25,6 +25,12 @@ def fail!(error_key) end end + class TestClassCustomizedUserVerification < TestClass + def user_verification_flag + nil + end + end + class TestCredentialFinder attr_accessor :expected_stored_credential @@ -131,6 +137,33 @@ def test_verify_authentication_and_find_stored_credential_success assert_nil @test_class.session["current_webauthn_authentication_challenge"] end + def test_verify_authentication_overridden_to_be_optional_and_find_stored_credential_success + relying_party = example_relying_party + client = fake_client + credential = create_credential(client: client, relying_party: relying_party) + + stored_credential = OpenStruct.new(external_id: Base64.strict_encode64(credential.id), public_key: relying_party.encoder.encode(credential.public_key)) + + raw_challenge = relying_party.options_for_authentication(user_verification: "required").challenge + + assertion = assertion_from_client(client: client, challenge: raw_challenge, user_verified: nil) + + credential_finder = TestCredentialFinder.new + credential_finder.expected_stored_credential = stored_credential + + @test_class = TestClassCustomizedUserVerification.new + @test_class.env['warden.webauthn.credential_finder'] = credential_finder + @test_class.env['warden.webauthn.relying_party'] = relying_party + + @test_class.session["current_webauthn_authentication_challenge"] = raw_challenge + + @test_class.params["credential"] = assertion.to_json + + assert_equal stored_credential, @test_class.verify_authentication_and_find_stored_credential + assert_nil @test_class.error_key + assert_nil @test_class.session["current_webauthn_authentication_challenge"] + end + def test_verify_authentication_and_find_stored_credential_user_not_verified relying_party = example_relying_party client = fake_client