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

Commit

Permalink
Merge pull request #517 from cpacia/master
Browse files Browse the repository at this point in the history
Remove authentication for localhost
  • Loading branch information
cpacia committed Jan 12, 2017
2 parents 248b43c + 51e7019 commit fd65bbc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class OpenBazaarAPI(APIResource):
def authenticated(func):
def _authenticate(self, request):
session = request.getSession()
if session not in self.authenticated_sessions:
if session not in self.authenticated_sessions and "localhost" not in self.authenticated_sessions:
session.expire()
request.setResponseCode(401)
request.write('<html><body><div><span style="color:red">Authorization Error</span></div>'
Expand Down
4 changes: 3 additions & 1 deletion api/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ class AuthenticatedWebSocketProtocol(WebSocketProtocol):
def validateHeaders(self):
if "Cookie" in self.headers:
for session in self.factory.authenticated_sessions:
if "TWISTED_SESSION=" + session.uid in self.headers["Cookie"]:
if session == "localhost":
return WebSocketProtocol.validateHeaders(self)
elif "TWISTED_SESSION=" + session.uid in self.headers["Cookie"]:
return WebSocketProtocol.validateHeaders(self)
return False

Expand Down
2 changes: 2 additions & 0 deletions openbazaard.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def on_bootstrap_complete(resp):

# websockets api
authenticated_sessions = []
if interface == "127.0.0.1":
authenticated_sessions.append("localhost")
ws_api = WSFactory(mserver, kserver, only_ip=ALLOWIP)
ws_factory = AuthenticatedWebSocketFactory(ws_api)
ws_factory.authenticated_sessions = authenticated_sessions
Expand Down

0 comments on commit fd65bbc

Please sign in to comment.