Skip to content

Commit 8eb21aa

Browse files
author
mslatour
committed
Added support for authentication for Neo4J
1 parent 0aae57a commit 8eb21aa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bulb/auth.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from rest_framework import exceptions
66
from rest_framework.compat import CsrfViewMiddleware
77
import requests
8+
import urlparse
89
import hashlib
910
import json
1011
import logging
@@ -111,7 +112,12 @@ def authenticate_credentials(self, userid, password):
111112
params = {"username": userid}
112113
headers = {'content-type': 'application/json'}
113114

114-
r = n4j2bulb(requests.post(N4J, data=json.dumps({"query": query, "params": params}), headers = headers), True)
115+
u = urlparse.urlparse(N4J)
116+
if u.username is None or u.password is None:
117+
r = n4j2bulb(requests.post(N4J, data=json.dumps({"query": query, "params": params}), headers = headers), True)
118+
else:
119+
r = n4j2bulb(requests.post(N4J, data=json.dumps({"query": query, "params": params}), headers = headers, auth=(u.username,u.password)), True)
120+
115121

116122
if (r['password'] == shaHTTP):
117123
# User found and right password given

0 commit comments

Comments
 (0)