This topic explains how to configure Active Directory (AD) authentication for an Alibaba Cloud Elasticsearch instance, which allows users with specific roles in an AD domain to access the instance.
Prerequisites
You have completed the following operations:
You have created an Alibaba Cloud Elasticsearch instance. This topic uses a version 7.10 instance as an example.
For more information, see Create an Alibaba Cloud Elasticsearch instance.
You have prepared an AD domain environment and data in the same VPC as your Alibaba Cloud Elasticsearch instance. This topic uses Windows Server 2012 as an example.
This topic uses the username ccy1 and the root domain ccy.com. For example, in the AD domain
ccy.com, create the userccy1@ccy.com(the logon name for pre-Windows 2000 versions isCCY\ccy1). On the Account tab of the user properties, select Password never expires and set Account expires to Never.
Limitations
Since October 2020, Alibaba Cloud Elasticsearch has adjusted its network architecture across different regions. This affects newly created instances in the following ways:
For instances on the old network architecture, you can use the SNAT feature or a self-managed Nginx proxy to access the public network.
For instances on the new network architecture, the AD feature is subject to network restrictions. You must use a PrivateLink connection to connect the VPCs. For configuration details, see Configure a PrivateLink connection. If you need to access the public network, you must configure an Nginx proxy for request forwarding.
For instances on the old network architecture, Alibaba Cloud Elasticsearch supports AD authentication only in a single availability zone.
For more information about the network architecture, see [Notice] Network Architecture Adjustment.
Procedure
Step 1: Obtain endpoint domain name (optional)
Elasticsearch clusters created in October 2020 or later are deployed in the new network architecture. These Elasticsearch clusters reside in the VPC of the Elasticsearch service account. If your Elasticsearch cluster is deployed in the new network architecture, you need to use the PrivateLink service to establish a private connection between the VPC and your VPC. Then, obtain the domain name of the related endpoint for future use. To obtain the domain name of an endpoint, perform the following steps:
- Create a Classic Load Balancer (CLB) instance that supports the PrivateLink service and resides in the same VPC as the created Elasticsearch cluster.
For more information, see Configure a PrivateLink connection.
Configure the CLB instance.
Specify the server that hosts LDAP as the backend server and set the listener port to 389.
For more information, see Configure a PrivateLink connection.
- Create an endpoint service.
For more information, see Configure a PrivateLink connection.
- Configure a private connection to the Elasticsearch cluster.
For more information, see Configure a PrivateLink connection.
- Obtain the domain name of the endpoint that is used to access the endpoint service.
For more information, see Configure a PrivateLink connection.
Note Record the obtained domain name, which will be used in subsequent configurations.
Step 2: Configure AD authentication
You can use Elasticsearch security features to communicate with an AD domain for user authentication. The security features communicate with the AD domain by using LDAP. Therefore, the active_directory realm is similar to the ldap realm. Like an LDAP directory, an AD domain stores users and groups hierarchically. The AD domain verifies a user's identity by sending an LDAP bind request. After verification, the AD domain searches for the user's entry in Active Directory. Once the user is found, the AD domain retrieves the user's group membership from the tokenGroups attribute of the user's entry in Active Directory. For more information, see Configuring an Active Directory realm.
For Alibaba Cloud Elasticsearch instances running versions 6.x, 7.x, or 8.x:
Add the following configuration to the YML file of the target Elasticsearch instance to set up AD authentication for the corresponding user. For more information, see Configure YML parameters.
For Alibaba Cloud Elasticsearch instances running other versions:
First, try adding the following configuration to the instance's YML file. If the configuration change fails to apply on the console and the instance does not restart, submit a ticket and ask technical support to apply the configuration.
xpack.security.authc.realms.active_directory.my_ad.order: 2
xpack.security.authc.realms.active_directory.my_ad.domain_name: ccy.com
xpack.security.authc.realms.active_directory.my_ad.url: ldap://ep-bp1i321219*******-cn-hangzhou-h.epsrv-bp15571d5ps*******.cn-hangzhou.privatelink.aliyuncs.com:389
xpack.security.authc.realms.active_directory.my_ad.bind_dn: cc**@ccy.com
xpack.security.authc.realms.active_directory.my_ad.bind_password: your_passwordParameter | Description |
order | The authentication order for this realm. Note In version 8.x, the |
domain_name | The name of the root domain. |
url | The URL and port number for the private connection to the AD domain. For more information, see Configuring an Active Directory realm. Important In the new network architecture, the value must be set to |
bind_dn | The user that performs all AD search requests. |
bind_password | The password for the |
Step 3: Map roles to domain accounts
Log on to your instance's Kibana console.
For more information, see Log on to the Kibana console.
NoteThe user interface may differ depending on your Kibana version.
On the Kibana homepage, click Developer Tools.
On the Console tab, run the following command to set the ccy1 user in the AD domain as an administrator.
PUT /_security/role_mapping/basic_users { "roles": [ "superuser" ], "enabled": true, "rules": { "any": [ { "field": { "groups": "cn=ali,dc=ccy,dc=com" } }, { "field": { "dn": "cn=ccy1,cn=ali,dc=ccy,dc=com" } } ] } }
Step 4: Verify the result
Log in to Kibana for the target Elasticsearch as the authorized ccy1 user.
On the Kibana homepage, click Developer Tools.
On the Console tab, run the following command to verify whether the ccy1 user has permission to perform the corresponding action.
GET _cat/indicesIf the ccy1 user has permissions, the following result is returned, which indicates that the permissions for the ccy1 user in the AD domain are configured successfully.
1 green open .apm-agent-configuration 4zvRAxNyTv6_xxx 1 1 0 0 522b 261b 2 green open .monitoring-kibana-7-2021.12.08 Kr9Om1WUQW67xxx 1 1 3732 0 1.9mb 1.1mb 3 green open product_info WPZ11CtfRL-hxxx 5 1 8 0 49.2kb 24.6kb 4 green open .kibana_1 ffs3ho7cTte0xxx 1 1 31 0 41.5mb 20.7mb 5 green open .monitoring-es-7-2021.12.08 1efDbJNWT8uRxxx 1 1 44838 74520 63.1mb 31.6mb 6 green open .security-7 Gu8XhA-yQ46mxxx 1 1 58 9 302.1kb 151kb 7 green open .monitoring-es-7-2021.12.06 PCVdQeP-R2SKxxx 1 1 111372 123120 140.5mb 70.2mb 8 green open .monitoring-es-7-2021.12.07 udTlD2Q_S1ylxxx 1 1 186883 157638 229.1mb 114.3mb 9 green open .apm-custom-link JVXx0qioQ9uMxxx 1 1 0 0 522b 261b 10 green open .kibana_task_manager_1 nDKy8KLASsevxxx 1 1 6 3036 720kb 357kb 11 green open .monitoring-kibana-7-2021.12.06 g0mwhwFaTduGxxx 1 1 12312 0 3.8mb 1.8mb 12 green open .monitoring-kibana-7-2021.12.07 xfW97NKTT_a6xxx 1 1 17248 0 5.8mb 2.9mb 13 green open .kibana-event-log-7.10.0-000001 rOefxK00Qtqrxxx 1 1 3 0 33.2kb 16.6kb 14 green open product_info1 VUF0kfAfSrG9xxx 1 1 8 0 11.9kb 5.9kb