Sha256: cf6096e8802f1a5e4181a61adc7e3ccf4b00af4758045eaeda756799b67eb950

Contents?: true

Size: 1.01 KB

Versions: 14

Compression:

Stored size: 1.01 KB

Contents

module Brightbox
  module Config
    module TwoFactorHelper
      attr_writer :two_factor_helper_password

      def two_factor_helper_command
        return config[client_name]["two_factor_helper_command"] unless client_name.nil?
      end

      # Return the two_factor code from the helper if it's possible
      def two_factor_helper_password
        if defined?(@two_factor_helper_password) && !@two_factor_helper_password.nil?
          return @two_factor_helper_password
        end

        @two_factor_helper_password = if two_factor_helper_command
                                        two_factor_helper_call
                                      end
      end

      private

      def two_factor_helper_call
        info "INFO: Calling two factor helper to obtain two factor"
        begin
          cmd = two_factor_helper_command.split(/\s+/)
          IO.popen(cmd, "r") do |io|
            io.readline.chomp
          end
        rescue ArgumentError, Errno::ENOENT
          nil
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
brightbox-cli-4.8.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.7.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.6.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.5.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.5.0.rc1 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.4.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.3.2 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.3.1 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.3.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.2.1 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.2.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.1.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.0.0 lib/brightbox-cli/config/two_factor_helper.rb
brightbox-cli-4.0.0.rc2 lib/brightbox-cli/config/two_factor_helper.rb