Module: Neo4j::Tasks::ConfigServer

Extended by:
ConfigServer
Included in:
ConfigServer
Defined in:
lib/neo4j/tasks/config_server.rb

Instance Method Summary collapse

Instance Method Details

#change_password(target_address, old_password, new_password) ⇒ Hash

POSTs to an endpoint with the form required to change a Neo4j password

Parameters:

  • target_address (String)

    The server address, with protocol and port, against which the form should be POSTed

  • old_password (String)

    The existing password for the “neo4j” user account

  • new_password (String)

    The new password you want to use. Shocking, isn’t it?

Returns:

  • (Hash)

    The response from the server indicating success/failure.



24
25
26
27
28
# File 'lib/neo4j/tasks/config_server.rb', line 24

def change_password(target_address, old_password, new_password)
  uri = URI.parse("#{target_address}/user/neo4j/password")
  response = Net::HTTP.post_form(uri,  'password' => old_password, 'new_password' => new_password)
  JSON.parse(response.body)
end

#config(source_text, port) ⇒ Object



4
5
6
7
# File 'lib/neo4j/tasks/config_server.rb', line 4

def config(source_text, port)
  s = set_property(source_text, 'org.neo4j.server.webserver.https.enabled', 'false')
  set_property(s, 'org.neo4j.server.webserver.port', port)
end

#set_property(source_text, property, value) ⇒ Object



9
10
11
# File 'lib/neo4j/tasks/config_server.rb', line 9

def set_property(source_text, property, value)
  source_text.gsub(/#{property}\s*=\s*(\w+)/, "#{property}=#{value}")
end

#toggle_auth(status, source_text) ⇒ Object

Toggles the status of Neo4j 2.2’s basic auth



14
15
16
17
# File 'lib/neo4j/tasks/config_server.rb', line 14

def toggle_auth(status, source_text)
  status_string = status == :enable ? 'true' : 'false'
  set_property(source_text, 'dbms.security.authorization_enabled', status_string)
end