Sha256: fb1e22d8dddb57181a8224a32437904fb314c5cb880bbb8c6771f444a1677f85

Contents?: true

Size: 1.4 KB

Versions: 8

Compression:

Stored size: 1.4 KB

Contents

module Neo4j
  module Tasks
    module ConfigServer
      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

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

      # Toggles the status of Neo4j 2.2's basic auth
      def toggle_auth(status, source_text)
        status_string = status == :enable ? 'true' : 'false'
        set_property(source_text, 'dbms.security.authorization_enabled', status_string)
      end

      # POSTs to an endpoint with the form required to change a Neo4j password
      # @param [String] target_address The server address, with protocol and port, against which the form should be POSTed
      # @param [String] old_password The existing password for the "neo4j" user account
      # @param [String] new_password The new password you want to use. Shocking, isn't it?
      # @return [Hash] The response from the server indicating success/failure.
      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

      extend self
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
neo4j-core-4.0.7 lib/neo4j/tasks/config_server.rb
neo4j-core-4.0.6 lib/neo4j/tasks/config_server.rb
neo4j-core-4.0.5 lib/neo4j/tasks/config_server.rb
neo4j-core-4.0.4 lib/neo4j/tasks/config_server.rb
neo4j-core-4.0.3 lib/neo4j/tasks/config_server.rb
neo4j-core-4.0.2 lib/neo4j/tasks/config_server.rb
neo4j-core-4.0.1 lib/neo4j/tasks/config_server.rb
neo4j-core-4.0.0 lib/neo4j/tasks/config_server.rb