module Aptible::CLI::Helpers::SecurityKey
Constants
- U2F_LOGGER
Public Class Methods
authenticate(origin, app_id, challenge, device, device_locations)
click to toggle source
# File lib/aptible/cli/helpers/security_key.rb, line 223 def self.authenticate(origin, app_id, challenge, device, device_locations) procs = Hash[device_locations.map do |location| params = AuthenticatorParameters.new( origin, challenge, app_id, device, location ) 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 w.formatted_out(out) if out end ensure procs.values.map(&:pid).each { |p| Process.kill(:SIGTERM, p) } end end
device_locations()
click to toggle source
# File lib/aptible/cli/helpers/security_key.rb, line 208 def self.device_locations w = DeviceMapper.spawn _, status = Process.wait2 _, out = w.exited(status) # parse output and only log device matches = out.split("\n").map { |s| s.match(/^(\S+):\s/) } results = [] matches.each do |m| capture = m.captures results << capture[0] if m && capture.count.positive? end results end