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.



27
28
29
30
31
# File 'lib/neo4j/tasks/config_server.rb', line 27

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
18
19
20
# File 'lib/neo4j/tasks/config_server.rb', line 14

def toggle_auth(status, source_text)
  status_string = status == :enable ? 'true' : 'false'
  %w(dbms.security.authorization_enabled dbms.security.auth_enabled).each do |key|
    source_text = set_property(source_text, key, status_string)
  end
  source_text
end