2
0
mirror of https://opendev.org/x/pyghmi synced 2026-05-18 04:07:19 +00:00

Merge "Fix nonce login"

This commit is contained in:
Zuul
2021-11-15 22:55:24 +00:00
committed by Gerrit Code Review
2 changed files with 9 additions and 8 deletions
+4 -8
View File
@@ -1035,18 +1035,14 @@ class XCCClient(IMMClient):
adata = json.dumps({'username': self.username,
'password': self.password
})
nonce = None
wc.request('POST', '/api/providers/get_nonce', '{}')
rsp = wc.getresponse()
tokbody = rsp.read()
if rsp.status == 200:
rsp = json.loads(tokbody)
nonce = rsp.get('nonce', None)
headers = {'Connection': 'keep-alive',
'Referer': 'https://xcc/',
'Host': 'xcc',
'Content-Type': 'application/json'}
if nonce:
rsp, status = wc.grab_json_response_with_status(
'/api/providers/get_nonce', {})
if status == 200:
nonce = rsp.get('nonce', None)
headers['Content-Security-Policy'] = 'nonce={0}'.format(nonce)
wc.request('POST', '/api/login', adata, headers)
rsp = wc.getresponse()
+5
View File
@@ -628,6 +628,11 @@ class OEMHandler(generic.OEMHandler):
'Referer': referer,
'Host': 'xcc',
'Content-Type': 'application/json'}
rsp, status = wc.grab_json_response_with_status(
'/api/providers/get_nonce', {})
if status == 200:
nonce = rsp.get('nonce', None)
headers['Content-Security-Policy'] = 'nonce={0}'.format(nonce)
wc.request('POST', '/api/login', adata, headers)
rsp = wc.getresponse()
if rsp.status == 200: