scholrly / neo4django

Drop-in Neo4j/Django integration.
GNU General Public License v3.0
358 stars 83 forks source link

Auth credentials not used by client when working with relationships #120

Closed robinedwards closed 12 years ago

robinedwards commented 12 years ago

Just been caught out by this bug whilst moving to production. Basically when I set http auth credentials for neo4j in OPTIONS the credentials don't get used for all requests.

The following code exercises the bug, you can see from the http requests made that some omit the http auth headers particulary a request to fetch all relationships:

u'GET /db/data/node/262/relationships/all HTTP/1.1\r\nHost: sharehoodvm:7474\r\nContent-Length: 2\r\naccept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\nconnection: close\r\naccept-encoding: *\r\naccept: application/json\r\nuser-agent: Neo4jPythonClient/1.7.0\r\n

from neo4jrestclient import options as neo_options 
from models import Town, Country
neo_options.DEBUG = True # prints all http requests to stdout

Country.objects.get(name="England").delete()
c = Country.objects.create(name='England')
c.save()
t  = Town.objects.create(name="London")
t.save()
t.is_in = c
t.save()

I have double checked with the following code that this isn't an issue with the neo4jrestclient, as all requests do contain the auth headers:

from neo4jrestclient import options as neo_options
from neo4jrestclient.client import GraphDatabase
from pprint import pprint as pp
import os
neo_options.DEBUG = True
gdb = GraphDatabase(os.environ.get('NEO4J_URL', None), username='foo', password='bar') 
jim = gdb.nodes.create(name="Jim")
bob = gdb.nodes.create(name="Bob")                                                                                                                  
jim.relationships.create("knows", bob)
pp(jim.relationships.outgoing(['knows']))

I am using the HEAD of both neo4django and neo4jrestclient repositories