diff options
author | Jenny Shen <jenny.shen@shopify.com> | 2023-02-15 10:52:32 -0500 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-04-12 11:57:15 +0900 |
commit | cd60113faa41384cba31781eeb8fa51ea3ed2355 (patch) | |
tree | dc916796c8a27111217e652488af79da0a0a4f3a /lib | |
parent | b6e860ba1bae04a1ce269a40ef4731fe52855a16 (diff) | |
download | ruby-cd60113faa41384cba31781eeb8fa51ea3ed2355.tar.gz |
Use Webauthn Listener in wait_for_otp
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/gemcutter_utilities.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb index 3ee8579933..c4f31dc0d6 100644 --- a/lib/rubygems/gemcutter_utilities.rb +++ b/lib/rubygems/gemcutter_utilities.rb @@ -2,6 +2,7 @@ require_relative "remote_fetcher" require_relative "text" +require_relative "webauthn_listener" ## # Utility methods for using the RubyGems API. @@ -260,13 +261,16 @@ module Gem::GemcutterUtilities end def wait_for_otp(webauthn_url) + server = TCPServer.new 0 + port = server.addr[1].to_s + thread = Thread.new do - Thread.current[:otp] = "Uvh6T57tkWuUnWYo" + Thread.current[:otp] = Gem::WebauthnListener.wait_for_otp_code(host, server) end thread.abort_on_exception = true thread.report_on_exception = false - url_with_port = "#{webauthn_url}?port=5678" + url_with_port = "#{webauthn_url}?port=#{port}" say "You have enabled multi-factor authentication. Please visit #{url_with_port} to authenticate via security device." thread.join |