Sha256: b66c0f6c149109bd127ed99451b121986901942a78da3afd8eac631e5daaac20

Contents?: true

Size: 743 Bytes

Versions: 37

Compression:

Stored size: 743 Bytes

Contents

# encoding: utf-8

require 'faraday'
require 'base64'

module Github
  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 # Github

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
github_api-0.11.3 lib/github_api/request/basic_auth.rb
github_api-0.11.2 lib/github_api/request/basic_auth.rb
github_api-0.11.1 lib/github_api/request/basic_auth.rb
github_api-0.11.0 lib/github_api/request/basic_auth.rb
github_api-0.10.2 lib/github_api/request/basic_auth.rb
github_api-0.10.1 lib/github_api/request/basic_auth.rb
github_api-0.10.0 lib/github_api/request/basic_auth.rb
github_api-0.9.7 lib/github_api/request/basic_auth.rb
github_api-0.9.6 lib/github_api/request/basic_auth.rb
github_api-0.9.5 lib/github_api/request/basic_auth.rb
github_api-0.9.4 lib/github_api/request/basic_auth.rb
github_api-0.9.3 lib/github_api/request/basic_auth.rb
github_api-0.9.2 lib/github_api/request/basic_auth.rb
github_api-0.9.1 lib/github_api/request/basic_auth.rb
github_api-0.9.0 lib/github_api/request/basic_auth.rb
github_api-0.8.11 lib/github_api/request/basic_auth.rb
github_api-0.8.10 lib/github_api/request/basic_auth.rb
github_api-0.8.9 lib/github_api/request/basic_auth.rb
github_api-0.8.8 lib/github_api/request/basic_auth.rb
github_api-0.8.7 lib/github_api/request/basic_auth.rb