fis USER_MANAGER section of config

This commit is contained in:
KF7EEL 2021-06-18 13:25:55 -07:00
parent 7db02fcb4b
commit c761e740bc
3 changed files with 109 additions and 111 deletions

View File

@ -156,7 +156,15 @@ def download_config(L_CONFIG_FILE, cli_file):
iterate_config.update(resp['masters'].copy())
corrected_config['SYSTEMS'].update(iterate_config)
corrected_config['LOGGER'].update(L_CONFIG_FILE['LOGGER'])
corrected_config['USER_MANAGER'].update(L_CONFIG_FILE['USER_MANAGER'])
## corrected_config['USER_MANAGER'].update(resp['config']['USER_MANAGER'])
## print(resp['config']['USER_MANAGER'])
corrected_config['USER_MANAGER'] = {}
corrected_config['USER_MANAGER']['THIS_SERVER_NAME'] = L_CONFIG_FILE['USER_MANAGER']['THIS_SERVER_NAME']
corrected_config['USER_MANAGER']['URL'] = L_CONFIG_FILE['USER_MANAGER']['URL']
corrected_config['USER_MANAGER']['SHARED_SECRET'] = L_CONFIG_FILE['USER_MANAGER']['SHARED_SECRET']
corrected_config['USER_MANAGER']['REMOTE_CONFIG_ENABLED'] = L_CONFIG_FILE['USER_MANAGER']['REMOTE_CONFIG_ENABLED']
corrected_config['USER_MANAGER'].update(resp['config']['USER_MANAGER'])
## iterate_config.update(resp['masters'].copy())
## print(iterate_config)
## print(iterate_config)
@ -238,13 +246,7 @@ def download_config(L_CONFIG_FILE, cli_file):
corrected_config['SYSTEMS'][i]['USE_ACL'] = iterate_config[i]['USE_ACL']
corrected_config['SYSTEMS'][i]['SUB_ACL'] = config.acl_build(iterate_config[i]['SUB_ACL'], 16776415)
## print(iterate_masters)
## for i in iterate_masters:
## iterate_masters['SYSTEMS']
## config.process_acls(corrected_config)
## print(corrected_config['SYSTEMS'])
## print('-------')
## print(corrected_config)
return corrected_config
# For exception, write blank dict
except requests.ConnectionError:
@ -825,6 +827,7 @@ class routerHBP(HBSYSTEM):
def __init__(self, _name, _config, _report):
HBSYSTEM.__init__(self, _name, _config, _report)
## print(_config)
self.name = _name
# list of self._targets for unit (subscriber, private) calls
@ -1352,26 +1355,12 @@ if __name__ == '__main__':
# Call the external routine to build the configuration dictionary
LOCAL_CONFIG = config.build_config(cli_args.CONFIG_FILE)
#print(LOCAL_CONFIG)
#print(download_config(LOCAL_CONFIG))
#if LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']:
#print(download_config(LOCAL_CONFIG)['config'])
## CONFIG = config.build_config(download_config(LOCAL_CONFIG))
#CONFIG = download_config(LOCAL_CONFIG)
#if not LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']:
## print(download_config(LOCAL_CONFIG)['config'])
## CONFIG = config.build_config(cli_args.CONFIG_FILE)
#print((CONFIG))
## config.process_acls(LOCAL_CONFIG)
if LOCAL_CONFIG['USER_MANAGER']['REMOTE_CONFIG_ENABLED']:
CONFIG = download_config(LOCAL_CONFIG, cli_args.CONFIG_FILE)
print('enabled')
else:
CONFIG = config.build_config(cli_args.CONFIG_FILE)
## print(CONFIG)
# Ensure we have a path for the rules file, if one wasn't specified, then use the default (top of file)
if not cli_args.RULES_FILE:
@ -1486,8 +1475,7 @@ if __name__ == '__main__':
BRIDGES = make_bridges(rules_module.BRIDGES)
# Get rule parameter for private calls
UNIT = rules_module.UNIT
for system in CONFIG['SYSTEMS']:
if CONFIG['SYSTEMS'][system]['ENABLED']:
if CONFIG['SYSTEMS'][system]['MODE'] == 'OPENBRIDGE':

View File

@ -339,7 +339,7 @@ class HBSYSTEM(DatagramProtocol):
if self._CONFIG['USER_MANAGER']['SHORTEN_PASSPHRASE'] == False:
pass
_calc_hash = bhex(sha256(_salt_str+calc_passphrase).hexdigest())
## print(calc_passphrase)
print(calc_passphrase)
# print(_calc_hash)
return _calc_hash

View File

@ -571,95 +571,95 @@ def create_app():
@login_required
def gen():
#print(str(gen_passphrase(3153591))) #(int(i[0])))
## try:
try:
#content = Markup('<strong>The HTML String</strong>')
#user_id = request.args.get('user_id')
u = current_user
## print(u.username)
id_dict = ast.literal_eval(u.dmr_ids)
#u = User.query.filter_by(username=user).first()
## print(user_id)
## print(request.args.get('mode'))
## if request.args.get('mode') == 'generated':
#print(id_dict)
content = '\n'
for i in id_dict.items():
if isinstance(i[1], int) == True and i[1] != 0:
link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8)
script_links[i[0]] = link_num
#print(script_links)
content = content + '''\n
<table style="width: 300px;" border="1">
<tbody>
<tr>
<td>
<p style="text-align: center;">Your passphrase for <strong>''' + str(i[0]) + '''</strong>:</p>
<p style="text-align: center;">Copy and paste: <strong>''' + str(gen_passphrase(int(i[0]))) + '''</strong></p>
<hr />
u = current_user
## print(u.username)
id_dict = ast.literal_eval(u.dmr_ids)
#u = User.query.filter_by(username=user).first()
## print(user_id)
## print(request.args.get('mode'))
## if request.args.get('mode') == 'generated':
#print(id_dict)
content = '\n'
for i in id_dict.items():
if isinstance(i[1], int) == True and i[1] != 0:
link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8)
script_links[i[0]] = link_num
#print(script_links)
content = content + '''\n
<table style="width: 300px;" border="1">
<tbody>
<tr>
<td>
<p style="text-align: center;">Your passphrase for <strong>''' + str(i[0]) + '''</strong>:</p>
<p style="text-align: center;">Copy and paste: <strong>''' + str(gen_passphrase(int(i[0]))) + '''</strong></p>
<hr />
<p style="text-align: center;">Phonetically spelled: <span style="text-decoration: underline;"><em>''' + convert_nato(str(gen_passphrase(int(i[0])))) + '''</em></span></p>
<p style="text-align: center;">Phonetically spelled: <span style="text-decoration: underline;"><em>''' + convert_nato(str(gen_passphrase(int(i[0])))) + '''</em></span></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
'''
elif i[1] == 0:
link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8)
script_links[i[0]] = link_num
#print(script_links)
content = content + '''\n
<table style="width: 300px;" border="1">
<tbody>
<tr>
<td>
<p style="text-align: center;">Your passphrase for <strong>''' + str(i[0]) + '''</strong>:</p>
<p style="text-align: center;">Copy and paste: <strong>''' + str(gen_passphrase(int(i[0]))) + '''</strong></p>
<hr />
<p style="text-align: center;">Phonetically spelled: <span style="text-decoration: underline;"><em>''' + convert_nato(str(gen_passphrase(int(i[0])))) + '''</em></span></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
'''
elif i[1] == '':
content = content + '''
<table style="width: 300px;" border="1">
<tbody>
<tr>
<td>
<p style="text-align: center;">Your passphrase for <strong>''' + str(i[0]) + '''</strong>:</p>
<p style="text-align: center;">Copy and paste: <strong>''' + legacy_passphrase + '''</strong></p>
<hr />
<p style="text-align: center;">Phonetically spelled: <span style="text-decoration: underline;"><em>''' + convert_nato(legacy_passphrase) + '''</em></span></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>'''
else:
content = content + '''
<table style="width: 300px;" border="1">
<tbody>
<tr>
<td>
<p style="text-align: center;">Your passphrase for <strong>''' + str(i[0]) + '''</strong>:</p>
<p style="text-align: center;">Copy and paste: <strong>''' + str(i[1]) + '''</strong></p>
<hr />
<p style="text-align: center;">Phonetically spelled: <span style="text-decoration: underline;"><em>''' + convert_nato(str(i[1])) + '''</em></span></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
'''
elif i[1] == 0:
link_num = str(random.randint(1,99999999)).zfill(8) + str(time.time()) + str(random.randint(1,99999999)).zfill(8)
script_links[i[0]] = link_num
#print(script_links)
content = content + '''\n
<table style="width: 300px;" border="1">
<tbody>
<tr>
<td>
<p style="text-align: center;">Your passphrase for <strong>''' + str(i[0]) + '''</strong>:</p>
<p style="text-align: center;">Copy and paste: <strong>''' + str(gen_passphrase(int(i[0]))) + '''</strong></p>
<hr />
<p style="text-align: center;">Phonetically spelled: <span style="text-decoration: underline;"><em>''' + convert_nato(str(gen_passphrase(int(i[0])))) + '''</em></span></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
'''
elif i[1] == '':
content = content + '''
<table style="width: 300px;" border="1">
<tbody>
<tr>
<td>
<p style="text-align: center;">Your passphrase for <strong>''' + str(i[0]) + '''</strong>:</p>
<p style="text-align: center;">Copy and paste: <strong>''' + legacy_passphrase + '''</strong></p>
<hr />
<p style="text-align: center;">Phonetically spelled: <span style="text-decoration: underline;"><em>''' + convert_nato(legacy_passphrase) + '''</em></span></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>'''
else:
content = content + '''
<table style="width: 300px;" border="1">
<tbody>
<tr>
<td>
<p style="text-align: center;">Your passphrase for <strong>''' + str(i[0]) + '''</strong>:</p>
<p style="text-align: center;">Copy and paste: <strong>''' + str(i[1]) + '''</strong></p>
<hr />
<p style="text-align: center;">Phonetically spelled: <span style="text-decoration: underline;"><em>''' + convert_nato(str(i[1])) + '''</em></span></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
'''
#content = content + '\n\n' + str(script_links[i[0]])
## except:
## content = Markup('<strong>No DMR IDs found or other error.</strong>')
except:
content = Markup('<strong>No DMR IDs found or other error.</strong>')
#return str(content)
@ -1987,6 +1987,12 @@ def create_app():
'STALE_TIME': i.ai_stale * 86400,
})
s_config['USER_MANAGER'].update({
'SHORTEN_LENGTH': shorten_length,
'SHORTEN_SAMPLE': shorten_sample,
'EXTRA_1': extra_1,
'EXTRA_2': extra_2,
'EXTRA_INT_1': extra_int_1,
'EXTRA_INT_2': extra_int_2,
'APPEND_INT': append_int,
'SHORTEN_PASSPHRASE': i.um_shorten_passphrase,
'BURN_FILE': i.um_burn_file,
@ -4792,8 +4798,12 @@ def create_app():
mode='override',
value=authorized_peer(hblink_req['login_id'])[1]
)
active_tgs[hblink_req['login_server']][hblink_req['system']] = [{'1':[]}, {'2':[]}, {'SYSTEM': ''}, {'peer_id':hblink_req['login_id']}]
print(active_tgs)
try:
active_tgs[hblink_req['login_server']][hblink_req['system']] = [{'1':[]}, {'2':[]}, {'SYSTEM': ''}, {'peer_id':hblink_req['login_id']}]
## print('Restart ' + hblink_req['login_server'] + ' please.')
except:
active_tgs[hblink_req['login_server']] = {}
pass
elif authorized_peer(hblink_req['login_id'])[0] == False:
## print('log fail')
authlog_add(hblink_req['login_id'], hblink_req['login_ip'], hblink_req['login_server'], 'Not Registered', '-', 'Failed')