Sha256: 83b87365ad0a6a3eb572ef0d6fb289a80ac2db1baf17cdb07db237309f48cc2f

Contents?: true

Size: 977 Bytes

Versions: 3

Compression:

Stored size: 977 Bytes

Contents

module Nucleus
  module Adapters
    module V1
      class Heroku < Stub
        # Authentication functionality to support the Heroku API
        module Authentication
          # @see Stub#auth_client
          def auth_client
            log.debug "Authenticate @ #{@endpoint_url}"
            TokenAuthClient.new @check_certificates do |verify_ssl, username, password|
              response = Excon.post("#{@endpoint_url}/login", query: { username: username, password: password },
                                   ssl_verify_peer: verify_ssl)
              # Heroku returns 404 for invalid credentials, then we do not return an API token
              if response.status == 404
                nil
              else
                # extract the token
                response_parsed = JSON.parse(response.body)
                response_parsed['api_key']
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nucleus-0.3.1 lib/nucleus/adapters/v1/heroku/authentication.rb
nucleus-0.2.0 lib/nucleus/adapters/v1/heroku/authentication.rb
nucleus-0.1.0 lib/nucleus/adapters/v1/heroku/authentication.rb