2
0
mirror of https://opendev.org/x/pyghmi synced 2026-04-03 16:46:26 +00:00

Fix nonce login

Redfish needed changes from ipmi side, also
need to tolerate a gzipped reply.

Change-Id: Ib9ffd4be9e4616d5a0b0a5d8ee35b140dd563ace
This commit is contained in:
Jarrod Johnson
2021-11-15 16:04:04 -05:00
parent da4120dd21
commit 97dc9cf1b1
2 changed files with 9 additions and 8 deletions

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()

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: