2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Add navigating nonce login for xcc discovery

The nonce login from newer firmware is now required.
This commit is contained in:
Jarrod Johnson 2021-11-12 11:27:58 -05:00
parent cde45bb170
commit d5e4d1b90a

View File

@ -148,6 +148,14 @@ class NodeHandler(immhandler.NodeHandler):
})
headers = {'Connection': 'keep-alive',
'Content-Type': 'application/json'}
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['Content-Security-Policy'] = 'nonce={0}'.format(nonce)
wc.request('POST', '/api/login', adata, headers)
rsp = wc.getresponse()
try:
@ -164,6 +172,14 @@ class NodeHandler(immhandler.NodeHandler):
})
headers = {'Connection': 'keep-alive',
'Content-Type': 'application/json'}
if nonce:
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['Content-Security-Policy'] = 'nonce={0}'.format(nonce)
wc.request('POST', '/api/login', adata, headers)
rsp = wc.getresponse()
try:
@ -375,6 +391,13 @@ class NodeHandler(immhandler.NodeHandler):
'password': tpass,
})
headers = {'Connection': 'keep-alive', 'Content-Type': 'application/json'}
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['Content-Security-Policy'] = 'nonce={0}'.format(nonce)
nwc.request('POST', '/api/login', adata, headers)
rsp = nwc.getresponse()
if rsp.status == 200: