Skip to content

Commit 3f145dc

Browse files
Merge pull request #7623 from jenshenny/fix-webauthn-poller
Rename credential email to identifier in WebAuthn poller (cherry picked from commit 53c6223)
1 parent a00987f commit 3f145dc

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/rubygems/gemcutter_utilities/webauthn_poller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ def webauthn_verification_poll_response(webauthn_url, credentials)
6969
rubygems_api_request(:get, "api/v1/webauthn_verification/#{webauthn_token}/status.json") do |request|
7070
if credentials.empty?
7171
request.add_field "Authorization", api_key
72+
elsif credentials[:identifier] && credentials[:password]
73+
request.basic_auth credentials[:identifier], credentials[:password]
7274
else
73-
request.basic_auth credentials[:email], credentials[:password]
75+
raise Gem::WebauthnVerificationError, "Provided missing credentials"
7476
end
7577
end
7678
end

test/rubygems/test_webauthn_poller.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def setup
1313
@fetcher = Gem::FakeFetcher.new
1414
Gem::RemoteFetcher.fetcher = @fetcher
1515
@credentials = {
16-
16+
identifier: "[email protected]",
1717
password: "password",
1818
}
1919
end
@@ -121,4 +121,14 @@ def test_poll_for_otp_invalid_status
121121
assert_equal error.message,
122122
"Security device verification failed: The token in the link you used has either expired or been used already."
123123
end
124+
125+
def test_poll_for_otp_missing_credentials
126+
@credentials = { password: "password" }
127+
128+
error = assert_raise Gem::WebauthnVerificationError do
129+
Gem::GemcutterUtilities::WebauthnPoller.new({}, @host).poll_for_otp(@webauthn_url, @credentials)
130+
end
131+
132+
assert_equal error.message, "Security device verification failed: Provided missing credentials"
133+
end
124134
end

0 commit comments

Comments
 (0)