Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit fd65bbc

Browse files
authored
Merge pull request #517 from cpacia/master
Remove authentication for localhost
2 parents 248b43c + 51e7019 commit fd65bbc

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

api/restapi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class OpenBazaarAPI(APIResource):
4444
def authenticated(func):
4545
def _authenticate(self, request):
4646
session = request.getSession()
47-
if session not in self.authenticated_sessions:
47+
if session not in self.authenticated_sessions and "localhost" not in self.authenticated_sessions:
4848
session.expire()
4949
request.setResponseCode(401)
5050
request.write('<html><body><div><span style="color:red">Authorization Error</span></div>'

api/ws.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ class AuthenticatedWebSocketProtocol(WebSocketProtocol):
367367
def validateHeaders(self):
368368
if "Cookie" in self.headers:
369369
for session in self.factory.authenticated_sessions:
370-
if "TWISTED_SESSION=" + session.uid in self.headers["Cookie"]:
370+
if session == "localhost":
371+
return WebSocketProtocol.validateHeaders(self)
372+
elif "TWISTED_SESSION=" + session.uid in self.headers["Cookie"]:
371373
return WebSocketProtocol.validateHeaders(self)
372374
return False
373375

openbazaard.py

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def on_bootstrap_complete(resp):
124124

125125
# websockets api
126126
authenticated_sessions = []
127+
if interface == "127.0.0.1":
128+
authenticated_sessions.append("localhost")
127129
ws_api = WSFactory(mserver, kserver, only_ip=ALLOWIP)
128130
ws_factory = AuthenticatedWebSocketFactory(ws_api)
129131
ws_factory.authenticated_sessions = authenticated_sessions

0 commit comments

Comments
 (0)