Open MiguelCasaresRobles opened 4 years ago
Hello Team,
I think it is better to add the LDAP server CA cert within the config.yml
( https://opendistro.github.io/for-elasticsearch-docs/docs/security/configuration/ldap/#certificate-validation OR https://opendistro.github.io/for-elasticsearch-docs/docs/security/configuration/ldap/#client-authentication) instead of using trustore in all Elasticserch nodes, An example :
ldap:
description: "Authenticate via LDAP or Active Directory"
http_enabled: true
transport_enabled: true
order: 1
http_authenticator:
type: basic
challenge: false
authentication_backend:
type: ldap
config:
enable_ssl: true
enable_start_tls: false
enable_ssl_client_auth: false
pemtrustedcas_filepath: /etc/elasticsearch/certs/ldapcacert.pem
verify_hostnames: true
hosts:
- test.ldap.com:636
bind_dn: 'cn=wali,ou=groups,dc=ldap,dc=com'
password: 'wazuh'
userbase: 'ou=groups,dc=ldap,dc=com'
usersearch: '(uid={0})'
username_attribute: uid
Then upload it to the .security
index using the securityadmin.sh
script:
/usr/share/elasticsearch/plugins/opendistro_security/tools/securityadmin.sh -cacert /etc/elasticsearch/certs/root-ca.pem -cert /etc/elasticsearch/certs/admin.pem -key /etc/elasticsearch/certs/admin.key -f /usr/share/elasticsearch/plugins/opendistro_security/securityconfig/config.yml -t config -icl -nhnv -h localhost
This way, we will not have to change/restart every Elasticsearch node and can be easily implemented.
Regards, El Wali
Hello team,
Opendistro has many security features that we may consider to add as a guide in our documentation. For instance:
LDAP INTEGRATION
Config.yml
Reference: https://opendistro.github.io/for-elasticsearch-docs/docs/security/configuration/ldap/
LDAP can handle both feature authentication and authorization.
auhtc
handling the configuration for authentication, for authorization we will need to useauthz
sections. Authorization is the process of retrieving backend roles for an authenticated user from an LDAP server. The file where both of the sections are configured is located here:/usr/share/elasticsearch/plugins/opendistro_security/securityconfig/config.yml
.In the
authc
section you will need to have/modify theldap
configuration.Where in the
config
:hosts
is yourldap
server and it's port (by default it is 389)bind_dn
the credential to authenticate to a LDAPpassword
password to authenticate to a LDAPThe Security plugin first takes the configured LDAP query and replaces the placeholder {0} with the user name from the user’s credentials.
usersearch: '(sAMAccountName={0})'
Then it issues this query against the user subtree. Currently, the entire subtree under the configured userbase is searched:
userbase: 'ou=people,dc=example,dc=com'
userbase
usersearch
username_attribute
To configure authorization in the same file add
authz
section:The Security plugin then issues the substituted query against the configured role subtree. The whole subtree below
rolebase
is searched.The Security plugin first takes the LDAP query for fetching roles (“rolesearch”) and substitutes any variables found in the query. Here
{0}
is substituted with the DN of the user:rolesearch: '(member={0})'
To update the Security plugin of OpenDistro you will need to run:
-cacert
path to the Root CA certificate-cert
path to the Admin Certificate-key
path to Admin Private KeyTo create a new role with
readonly
permission. In the fileroles.yml
:In the
roles_mapping.yml
:This file will map
ReadOnlyRole
to theLDAP-Read-Group
fromLDAP
.This command will udpate roles:
This command will update role mapping:
Elasticsearch.yml
The config map for the
elasticsearch.yml
:These three configurations were added to default config map:
truststore.jks
is the path to the trustore file that we will generate below.binpassword
the password you set during the generation of the trustore certificategoogle-ca
the alias you set during the generation of the trustore certificateGenerate the
trustore
(google_ldap)In this example, we will work with ldap.google.com.
To generate a truststore we will need to have CA authority certificate. In our case it will be the one from ldap.google.com
We have the file
google-ca.pem
:We will need to add this file to
To generate we need to run the following commands:
It will create the file
trusture.jks
.Note: need more testing
Regards,
Miguel Casares