mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
Process Token from query string instead of cookie header on the api side
for the socket.io service
This commit is contained in:
@@ -49,23 +49,21 @@ class TowerBaseNamespace(BaseNamespace):
|
|||||||
return set(['recv_connect'])
|
return set(['recv_connect'])
|
||||||
|
|
||||||
def valid_user(self):
|
def valid_user(self):
|
||||||
if 'HTTP_COOKIE' not in self.environ:
|
if 'QUERY_STRING' not in self.environ:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
all_keys = [e.strip() for e in self.environ['HTTP_COOKIE'].split(";")]
|
k, v = self.environ['QUERY_STRING'].split("=")
|
||||||
for each_key in all_keys:
|
if k == "Token":
|
||||||
k, v = each_key.split("=")
|
token_actual = urllib.unquote_plus(v).decode().replace("\"","")
|
||||||
if k == "token":
|
auth_token = AuthToken.objects.filter(key=token_actual)
|
||||||
token_actual = urllib.unquote_plus(v).decode().replace("\"","")
|
if not auth_token.exists():
|
||||||
auth_token = AuthToken.objects.filter(key=token_actual)
|
return False
|
||||||
if not auth_token.exists():
|
auth_token = auth_token[0]
|
||||||
return False
|
if not auth_token.expired:
|
||||||
auth_token = auth_token[0]
|
return auth_token.user
|
||||||
if not auth_token.expired:
|
else:
|
||||||
return auth_token.user
|
return False
|
||||||
else:
|
|
||||||
return False
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.error("Exception validating user: " + str(e))
|
logger.error("Exception validating user: " + str(e))
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user