Method: Neography::Connection#authenticate

Defined in:
lib/neography/connection.rb

#authenticate(path = nil) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/neography/connection.rb', line 93

def authenticate(path = nil)
  unless @authentication.empty?
    auth_type = @authentication.keys.first
    @client.set_auth(
      path,
      @authentication[auth_type][:username],
      @authentication[auth_type][:password]
    )
    # Force http client to always send auth credentials without
    # waiting for WWW-Authenticate headers, thus saving one request
    # roundtrip for each URI. Only works for HTTP basic auth.
    @client.www_auth.basic_auth.challenge(configuration) if auth_type == 'basic_auth'
  end
end