forked from wazuh/wazuh-docker
Merge pull request #2405 from wazuh/bug/2404-wazuh-manager4104-rc1-docker-container-fails-to-start-error-5011-in-create_userpy
Changed `update_user` function from `wazuh.security` to `wazuh.rbac.orm` module
This commit is contained in:
@@ -34,20 +34,6 @@ file:
|
|||||||
group: wazuh
|
group: wazuh
|
||||||
filetype: file
|
filetype: file
|
||||||
contains: []
|
contains: []
|
||||||
/var/ossec/etc/sslmanager.cert:
|
|
||||||
exists: true
|
|
||||||
mode: "0640"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
filetype: file
|
|
||||||
contains: []
|
|
||||||
/var/ossec/etc/sslmanager.key:
|
|
||||||
exists: true
|
|
||||||
mode: "0640"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
filetype: file
|
|
||||||
contains: []
|
|
||||||
package:
|
package:
|
||||||
filebeat:
|
filebeat:
|
||||||
installed: true
|
installed: true
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
- Changed update_user function from wazuh.security to wazuh.rbac.orm module ([#2405](https://github.com/wazuh/wazuh-docker/pull/2405))
|
||||||
- Add wazuh-template.json into permanent data exception ([#1967](https://github.com/wazuh/wazuh-docker/pull/1967))
|
- Add wazuh-template.json into permanent data exception ([#1967](https://github.com/wazuh/wazuh-docker/pull/1967))
|
||||||
|
|
||||||
### Deleted
|
### Deleted
|
||||||
|
|||||||
@@ -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