forked from wazuh/wazuh-docker
change update_user used function from wazuh.security to wazuh.rbac.orm
This commit is contained in:
@@ -13,13 +13,12 @@ SPECIAL_CHARS = "@$!%*?&-_"
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from wazuh.rbac.orm import check_database_integrity
|
from wazuh.rbac.orm import check_database_integrity, AuthenticationManager
|
||||||
from wazuh.security import (
|
from wazuh.security import (
|
||||||
create_user,
|
create_user,
|
||||||
get_users,
|
get_users,
|
||||||
get_roles,
|
get_roles,
|
||||||
set_user_role,
|
set_user_role,
|
||||||
update_user,
|
|
||||||
)
|
)
|
||||||
except ModuleNotFoundError as e:
|
except ModuleNotFoundError as e:
|
||||||
logging.error("No module 'wazuh' found.")
|
logging.error("No module 'wazuh' found.")
|
||||||
@@ -54,12 +53,11 @@ def disable_user(uid):
|
|||||||
# assure there must be at least one character from each group
|
# assure there must be at least one character from each group
|
||||||
random_pass = random_pass + ''.join([random.choice(chars) for chars in [string.ascii_lowercase, string.digits, string.ascii_uppercase, SPECIAL_CHARS]])
|
random_pass = random_pass + ''.join([random.choice(chars) for chars in [string.ascii_lowercase, string.digits, string.ascii_uppercase, SPECIAL_CHARS]])
|
||||||
random_pass = ''.join(random.sample(random_pass,len(random_pass)))
|
random_pass = ''.join(random.sample(random_pass,len(random_pass)))
|
||||||
update_user(
|
with AuthenticationManager() as auth:
|
||||||
user_id=[
|
auth.update_user(
|
||||||
str(uid),
|
user_id=uid,
|
||||||
],
|
password=random_pass,
|
||||||
password=random_pass,
|
)
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@@ -90,12 +88,11 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
# modify an existing user ("wazuh" or "wazuh-wui")
|
# modify an existing user ("wazuh" or "wazuh-wui")
|
||||||
uid = initial_users[username]
|
uid = initial_users[username]
|
||||||
update_user(
|
with AuthenticationManager() as auth:
|
||||||
user_id=[
|
auth.update_user(
|
||||||
str(uid),
|
user_id=uid,
|
||||||
],
|
password=password,
|
||||||
password=password,
|
)
|
||||||
)
|
|
||||||
# disable unused default users
|
# disable unused default users
|
||||||
for def_user in ['wazuh', 'wazuh-wui']:
|
for def_user in ['wazuh', 'wazuh-wui']:
|
||||||
if def_user != username:
|
if def_user != username:
|
||||||
|
|||||||
Reference in New Issue
Block a user