website/integrations/monitoring/wazuh/index.mdx
Wazuh is a security platform that aims to safeguard data assets across multiple environments including on-site, virtualized, containerized, and cloud-based.
The following placeholders are used in this guide:
wazuh-dashboard.company is the FQDN of the Wazuh Dashboard installation.wazuh-indexer.company is the FQDN of the Wazuh Indexer installationauthentik.company is the FQDN of the authentik installation.:::info This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application. :::
To support the integration of Wazuh with authentik, you need to create a group, a property mapping, and an application/provider pair in authentik.
wazuh-administrators) and click Create.Log in to authentik as an administrator and open the authentik Admin interface.
Navigate to Customization > Property Mappings and click Create. Create a SAML Provider Property Mapping with the following settings:
Roleswazuh-administrators is used as a placeholder for the group name.if ak_is_group_member(request.user, name="wazuh-administrators"):
yield "wazuh-admin"
Click Finish.
Wazuh), an optional group for the type of application, the policy engine mode, and optional UI settings.https://wazuh-dashboard.company/_opendistro/_security/saml/acswazuh-samlPostauthentik default SAML Mapping: Name or authentik default SAML Mapping: Email)Provider for wazuh).SAML Metadata file and it will be required in the next section.To support the integration of authentik with Wazuh, you will need to configure SAML authentication on the Wazuh Indexer server and create role mappings on the Wazuh Dashboard server.
:::info
The file wazuh_authentik_meta.xml serves as a placeholder for your SAML Metadata file. Ensure that the filename used in this context matches the name of your SAML Metadata file.
:::
For the next step, you will need an exchange key. To generate this key, use the following command:
openssl rand -hex 32
Copy the downloaded metadata file to the /etc/wazuh-indexer/opensearch-security/ directory on your Wazuh Indexer server.
Change the ownership of the wazuh_authentik_meta.xml file to the wazuh-indexer user using the following command:
chown wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/opensearch-security/wazuh_authentik_meta.xml
Edit the /etc/wazuh-indexer/opensearch-security/config.yml on your Wazuh Indexer server.
Add a saml_auth_domain section after the basic_internal_auth_domain section. For example:
---
authc:
basic_internal_auth_domain:
description: "Authenticate SAML against internal users database"
http_enabled: true
transport_enabled: true
order: 0
http_authenticator:
type: basic
challenge: false
authentication_backend:
type: intern
saml_auth_domain:
http_enabled: true
transport_enabled: false
order: 1
http_authenticator:
type: saml
challenge: true
config:
idp:
metadata_file: "/etc/wazuh-indexer/opensearch-security/wazuh_authentik_meta.xml"
entity_id: "wazuh-saml"
sp:
entity_id: "wazuh-saml"
kibana_url: "https://wazuh-dashboard.company/"
roles_key: Roles
exchange_key: "<exchange key generated in step 1>"
authentication_backend:
type: noop
:::info
Ensure that you set the following parameters in the basic_internal_auth_domain section: order: 0 and challenge: false
And the metadata_file, kibana_url, and exchange_key parameters in the saml_auth_domain section.
:::
Run the securityadmin.sh script to load the configuration changes made in the /etc/wazuh-indexer/opensearch-security/config.yml file, ensure that you update the -h flag to your Wazuh Indexer FQDN:
export JAVA_HOME=/usr/share/wazuh-indexer/jdk/ && bash /usr/share/wazuh-indexer/plugins/opensearch-security/tools/securityadmin.sh -f /etc/wazuh-indexer/opensearch-security/config.yml -icl -key /etc/wazuh-indexer/certs/admin-key.pem -cert /etc/wazuh-indexer/certs/admin.pem -cacert /etc/wazuh-indexer/certs/root-ca.pem -h wazuh-indexer.company -nhnv
Edit the /etc/wazuh-indexer/opensearch-security/roles_mapping.yml file and include wazuh_admin as a backend_role in the appropriate section. The following example adds the role to the all_access section:
all_access:
reserved: true
hidden: false
backend_roles:
// highlight-next-line
- "wazuh-admin"
- "admin"
hosts: []
users: []
and_backend_roles: []
description: "Maps admin to all_access"
Run the securityadmin.sh script again but with the -f flag set to /etc/wazuh-indexer/opensearch-security/roles_mapping.yml, ensure that you update the -h flag to your Wazuh Indexer FQDN:
export JAVA_HOME=/usr/share/wazuh-indexer/jdk/ && bash /usr/share/wazuh-indexer/plugins/opensearch-security/tools/securityadmin.sh -f /etc/wazuh-indexer/opensearch-security/roles_mapping.yml -icl -key /etc/wazuh-indexer/certs/admin-key.pem -cert /etc/wazuh-indexer/certs/admin.pem -cacert /etc/wazuh-indexer/certs/root-ca.pem -h wazuh-indexer.company -nhnv
On the Wazuh Dashboard server, check the value of run_as in the /usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml configuration file:
hosts:
- default:
url: https://127.0.0.1
port: 55000
username: wazuh-wui
password: "<WAZUH_WUI_PASSWORD>"
// highlight-next-line
run_as: false
The run_as parameter, when set to true, enables the assignment of roles to users based on authorization context information. See the Wazuh Authorization Context documentation for more information.
If run_as is set to false, proceed to step 4. If run_as is set to true, proceed with the following steps to add a role mapping on the Wazuh dashboard.
On the Wazuh dashboard, click the upper-left menu icon ☰ to open the menu, then go to Server management > Security > Roles mapping.
Click Create Role mapping and configure the following parameters:
administrator)backend_rolesFINDwazuh-adminClick Save role mapping
On the Wazuh Dashboard server, add these lines to the /etc/wazuh-dashboard/opensearch_dashboards.yml file:
opensearch_security.auth.type: "saml"
server.xsrf.allowlist:
[
"/_opendistro/_security/saml/acs",
"/_opendistro/_security/saml/logout",
"/_opendistro/_security/saml/acs/idpinitiated",
]
opensearch_security.session.keepalive: false
Restart the Wazuh dashboard service using the following command:
sudo systemctl restart wazuh-dashboard
To confirm that authentik is properly configured with Wazuh, log out and log back in using an account that is a member of the appropriate authentik group (e.g. wazuh-administrators).