Module: Aptible::CLI::Helpers::SecurityKey
- Defined in:
- lib/aptible/cli/helpers/security_key.rb
Defined Under Namespace
Classes: Authenticator, AuthenticatorParameters, Device, ThrottledAuthenticator
Constant Summary collapse
- U2F_LOGGER =
Logger.new( ENV['U2F_DEBUG'] ? STDERR : File.open(File::NULL, 'w') )
Class Method Summary collapse
Class Method Details
.authenticate(origin, app_id, challenge, devices) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/aptible/cli/helpers/security_key.rb', line 109 def self.authenticate(origin, app_id, challenge, devices) procs = Hash[devices.map do |device| params = AuthenticatorParameters.new( origin, challenge, app_id, device ) w = Authenticator.spawn(params) [w.pid, w] end] begin loop do pid, status = Process.wait2 w = procs.delete(pid) raise "waited unknown pid: #{pid}" if w.nil? r, out = w.exited(status) procs[r.pid] = r if r return out if out end ensure procs.values.map(&:pid).each { |p| Process.kill(:SIGTERM, p) } end end |