mirror of
https://opendev.org/x/pyghmi
synced 2026-05-18 12:17:19 +00:00
Support nonce based web login
Support the newer web loogin procedure that requires a nonce to get going. Change-Id: Ia6c532f0e18d2b101ca9cd9ba1c539fdedea2862
This commit is contained in:
@@ -1035,10 +1035,19 @@ 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:
|
||||
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