summaryrefslogtreecommitdiff
path: root/lib/rubygems/gemcutter_utilities.rb
diff options
context:
space:
mode:
authorJenny Shen <[email protected]>2023-06-29 16:10:22 -0400
committergit <[email protected]>2023-07-28 16:08:08 +0000
commitfce04f9a6c9935ef3f188558dce177e277b17711 (patch)
tree9ba20fcc264f156ba6c7dc142870d3c59f021dd7 /lib/rubygems/gemcutter_utilities.rb
parent108cc38a7658bfb8e9457f95baa5cdfbd175b64d (diff)
[rubygems/rubygems] Move WebauthnListener into the Gem::GemcutterUtilities namespace
https://github.com/rubygems/rubygems/commit/3080394f81
Diffstat (limited to 'lib/rubygems/gemcutter_utilities.rb')
-rw-r--r--lib/rubygems/gemcutter_utilities.rb18
1 files changed, 2 insertions, 16 deletions
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index fb1a42b5ce..074a0df334 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -2,7 +2,7 @@
require_relative "remote_fetcher"
require_relative "text"
-require_relative "webauthn_listener"
+require_relative "gemcutter_utilities/webauthn_listener"
require_relative "gemcutter_utilities/webauthn_poller"
##
@@ -260,7 +260,7 @@ module Gem::GemcutterUtilities
url_with_port = "#{webauthn_url}?port=#{port}"
say "You have enabled multi-factor authentication. Please visit #{url_with_port} to authenticate via security device. If you can't verify using WebAuthn but have OTP enabled, you can re-run the gem signin command with the `--otp [your_code]` option."
- threads = [socket_thread(server), WebauthnPoller.poll_thread(options, host, webauthn_url, credentials)]
+ threads = [WebauthnListener.listener_thread(host, server), WebauthnPoller.poll_thread(options, host, webauthn_url, credentials)]
otp_thread = wait_for_otp_thread(*threads)
threads.each(&:join)
@@ -289,20 +289,6 @@ module Gem::GemcutterUtilities
threads.each(&:exit)
end
- def socket_thread(server)
- thread = Thread.new do
- Thread.current[:otp] = Gem::WebauthnListener.wait_for_otp_code(host, server)
- rescue Gem::WebauthnVerificationError => e
- Thread.current[:error] = e
- ensure
- server.close
- end
- thread.abort_on_exception = true
- thread.report_on_exception = false
-
- thread
- end
-
def webauthn_verification_url(credentials)
response = rubygems_api_request(:post, "api/v1/webauthn_verification") do |request|
if credentials.empty?