Sha256: fa41e097ff3d4cdbecfd8b5167666a0f13d0c6e872010dae631e040d551a455b

Contents?: true

Size: 590 Bytes

Versions: 7

Compression:

Stored size: 590 Bytes

Contents

require 'highline/import'

module HaveAPI::Fs::Auth
  class Basic < Base
    register :basic

    def self.use?(opts)
      opts[:user] || opts[:password]
    end

    def setup
      @user = @opts[:user] || @cfg[:user]
      @passwd = @opts[:password] || @cfg[:password]
    end

    def validate
      @user ||= ask('User name: ') { |q| q.default = nil }.to_s

      @passwd ||= ask('Password: ') do |q|
        q.default = nil
        q.echo = false
      end.to_s
    end

    def authenticate(client)
      client.authenticate(:basic, user: @user, password: @passwd)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
haveapi-fs-0.11.0 lib/haveapi/fs/auth/basic.rb
haveapi-fs-0.10.0 lib/haveapi/fs/auth/basic.rb
haveapi-fs-0.9.0 lib/haveapi/fs/auth/basic.rb
haveapi-fs-0.8.0 lib/haveapi/fs/auth/basic.rb
haveapi-fs-0.7.1 lib/haveapi/fs/auth/basic.rb
haveapi-fs-0.7.0 lib/haveapi/fs/auth/basic.rb
haveapi-fs-0.1.0 lib/haveapi/fs/auth/basic.rb