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

Commit 51e7019

Browse files
committed
Remove authentication for localhost
1 parent 9bc3b6b commit 51e7019

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

api/restapi.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ def on_bootstrap_complete(resp):
120120

121121
# websockets api
122122
authenticated_sessions = []
123+
if interface == "127.0.0.1":
124+
authenticated_sessions.append("localhost")
123125
ws_api = WSFactory(mserver, kserver, only_ip=ALLOWIP)
124126
ws_factory = AuthenticatedWebSocketFactory(ws_api)
125127
ws_factory.authenticated_sessions = authenticated_sessions

0 commit comments

Comments
 (0)