Sha256: 13bd9d958cac860f6199620ae91f45845323ffe0c2c60cf0fd57bba21b8c6afd

Contents?: true

Size: 749 Bytes

Versions: 16

Compression:

Stored size: 749 Bytes

Contents

# encoding: utf-8

require 'faraday'
require 'base64'

module BitBucket
  module Request
    class BasicAuth < Faraday::Middleware
      dependency 'base64'

      def call(env)
        env[:request_headers].merge!('Authorization' => "Basic #{@auth}\"")

        @app.call env
      end

      def initialize(app, *args)
        @app = app
        credentials = ""
        options = args.extract_options!
        if options.has_key? :login
          credentials = "#{options[:login]}:#{options[:password]}"
        elsif options.has_key? :basic_auth
          credentials = "#{options[:basic_auth]}"
        end
        @auth = Base64.encode64(credentials)
        @auth.gsub!("\n", "")
      end
    end # BasicAuth
  end # Request
end # BitBucket

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
zz_bitbucket_rest_api-0.1.11 lib/bitbucket_rest_api/request/basic_auth.rb
zz_bitbucket_rest_api-0.1.10 lib/bitbucket_rest_api/request/basic_auth.rb
zz_bitbucket_rest_api-0.1.9 lib/bitbucket_rest_api/request/basic_auth.rb
zz_bitbucket_rest_api-0.1.8 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api2-0.9.5 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api2-0.9.1 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api2-0.2.2 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api2-0.2.1 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api2-0.2.0 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api-0.1.7 lib/bitbucket_rest_api/request/basic_auth.rb
reenhanced_bitbucket_api-0.1.6 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api-0.1.5 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api-0.1.4 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api-0.1.2 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api-0.1.1 lib/bitbucket_rest_api/request/basic_auth.rb
bitbucket_rest_api-0.1.0 lib/bitbucket_rest_api/request/basic_auth.rb