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:
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user