v7.3.2.0: Refactor auth.py and rollback version in installation.py

In auth.py, removed an unnecessary pass statement and reassigned unused bind variables. Also, added a check to assign a default value to 'session_ttl' if it is None. In installation.py, rolled back the nginxinc.nginx version used during ansible galaxy installation from 0.24.2 to 0.24.1.
pull/390/head
Aidaho 2024-07-07 21:03:47 +03:00
parent 60bc04d5af
commit 04e2edf517
2 changed files with 5 additions and 4 deletions

View File

@ -52,7 +52,6 @@ def is_admin(level=1, **kwargs):
role = user_sql.get_user_role_by_uuid(user_id, group_id)
except Exception:
role = 4
pass
try:
return True if int(role) <= int(level) else False
except Exception:
@ -84,13 +83,13 @@ def check_in_ldap(user, password):
ldap_bind.protocol_version = ldap.VERSION3
ldap_bind.set_option(ldap.OPT_REFERRALS, 0)
bind = ldap_bind.simple_bind_s(root_user, root_password)
_ = ldap_bind.simple_bind_s(root_user, root_password)
criteria = "(&(objectClass=" + ldap_class_search + ")(" + ldap_user_attribute + "=" + user + "))"
attributes = [ldap_search_field]
result = ldap_bind.search_s(ldap_base, ldap.SCOPE_SUBTREE, criteria, attributes)
bind = ldap_bind.simple_bind_s(result[0][0], password)
_ = ldap_bind.simple_bind_s(result[0][0], password)
except ldap.INVALID_CREDENTIALS:
return False
except ldap.SERVER_DOWN:
@ -116,6 +115,8 @@ def do_login(user_uuid: str, user_group: str, user: str, next_url: str):
session_ttl = sql.get_setting('session_ttl')
except Exception:
session_ttl = 5
if session_ttl is None:
session_ttl = 5
if next_url:
redirect_to = f'https://{request.host}{next_url}'

View File

@ -176,7 +176,7 @@ def generate_service_inv(json_data: json, installed_service: str) -> object:
is_docker = json_data['services'][installed_service]['docker']
if installed_service == 'nginx' and not os.path.isdir('/var/www/haproxy-wi/app/scripts/ansible/roles/nginxinc.nginx'):
os.system('ansible-galaxy install nginxinc.nginx,0.24.2 --roles-path /var/www/haproxy-wi/app/scripts/ansible/roles/')
os.system('ansible-galaxy install nginxinc.nginx,0.24.1 --roles-path /var/www/haproxy-wi/app/scripts/ansible/roles/')
for k, v in json_data['servers'].items():
server_ip = v['ip']