Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

neo4j produces "No authorization header supplied" error

I'm trying to access neo4j running on an aws ec2 instance from the command line where I get authorisation errors. I've enabled org.neo4j.server.webserver.address=0.0.0.0 and get a 503 error on the first statement and the same errors for the rest using the ec2 host name.

ubuntu@ip-10-0-0-192:/etc/neo4j$ curl http://localhost:7474/
{
  "management" : "http://localhost:7474/db/manage/",
  "data" : "http://localhost:7474/db/data/"
}ubuntu@ip-10-0-0-192:/etc/neo4j$ curl http://localhost:7474/db/data/
{
  "errors" : [ {
    "message" : "No authorization header supplied.",
    "code" : "Neo.ClientError.Security.AuthorizationFailed"
  } ]
}ubuntu@ip-10-0-0-192:/etc/neo4j$ curl http://localhost:7474/user/neo4j/
{
  "errors" : [ {
    "message" : "No authorization header supplied.",
    "code" : "Neo.ClientError.Security.AuthorizationFailed"
  } ]
ubuntu@ip-10-0-0-192:/etc/neo4j$ curl http://localhost:7474/user/neo4j/password
{
  "errors" : [ {
    "message" : "No authorization header supplied.",
    "code" : "Neo.ClientError.Security.AuthorizationFailed"
  } ]

Am I logging in correctly or have I missed a step somewhere?

Any help is appreciated.

like image 597
Rhys Avatar asked Aug 12 '15 13:08

Rhys


2 Answers

You need to provide authorization header in your request

Authorization: Basic bmVvNGo6bmVvNGo=

curl --header "Authorization: Basic bmVvNGo6bmVvNGo=" http://localhost:7474

bmVvNGo6bmVvNGo= is default Neo4j password: neo4j

by @michael-hunger

note: For the auth APIs you still need authorization.

curl -u neo4j:password http://localhost:7474

Or turn off authorization in Neo4j configuration

conf/neo4j-server.properties

# Disable authorization 
dbms.security.auth_enabled=false

Here is more information about that

http://neo4j.com/docs/stable/rest-api-security.html

like image 71
MicTech Avatar answered Nov 10 '22 15:11

MicTech


The steps below will construct an "Authorization" header that will work when curling Neo4j REST APIs. This works in Neo4j Community 4.4.7 (probably with earlier versions, too). Assuming that username = "neo4j" and password = "am4zeftw":

  1. You need to construct a base64 encoding of the username and password combination. If you use the correct format – "user:password" – as input into base64, you'll get a correctly formatted string as output. The example below generates bmVvNGo6YW00emVmdHc= for username "neo4j" and password "am4zeftw":

    echo -n 'neo4j:am4zeftw' | base64
    bmVvNGo6YW00emVmdHc=
    
  2. Construct the header itself, using the output from base64:

    -H 'Authorization:Basic bmVvNGo6YW00emVmdHc='
    
  3. Include that header in your curl command, like this:

    curl -H 'Authorization:Basic bmVvNGo6YW00emVmdHc=' \
    -X POST -H 'Content-type: application/json' \
    http://11.22.33.44:7474/db/data/transaction/commit -d "..."
    
like image 1
kaan Avatar answered Nov 10 '22 17:11

kaan