Skip to content

Commit a94c619

Browse files
authored
LDAP automatic user provisioning (#20033)
1 parent f319974 commit a94c619

15 files changed

+513
-283
lines changed

src/current/_includes/releases/v25.3/v25.3.0-rc.1.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Release Date: July 23, 2025
1212
[#150366][#150366]
1313
- The session setting `optimizer_min_row_count`, which sets a lower bound on row count estimates for relational expressions during query planning, is now set to `1` by default.
1414
[#150376][#150376]
15+
- The `options` column in the output of `SHOW ROLES` and `SHOW USERS` is now returned as an array of strings (e.g., `{NOLOGIN,CREATEDB}`) rather than as a single comma-separated string. This enables more efficient querying of role options using array functions like `unnest()`. For example: `SELECT * FROM [SHOW ROLES] AS r WHERE EXISTS (SELECT 1 FROM unnest(r.options) AS m(option) WHERE option LIKE 'SUBJECT=cn%');`
16+
[#149537][#149537]
17+
- The `SHOW ROLES` and `SHOW USERS` commands now include an `estimated_last_login_time` column that displays the estimated timestamp of when each user last authenticated to the database. This column shows `NULL` for users who have never logged in, and for existing users after upgrading to v25.3 until their next login. The tracking is performed on a best-effort basis and may not capture every login event.
18+
[#149537][#149537]
1519

1620
<h3 id="v25-3-0-rc-1-operational-changes">Operational changes</h3>
1721

@@ -50,3 +54,4 @@ Release Date: July 23, 2025
5054
[#149920]: https://github.com/cockroachdb/cockroach/pull/149920
5155
[#150296]: https://github.com/cockroachdb/cockroach/pull/150296
5256
[#150016]: https://github.com/cockroachdb/cockroach/pull/150016
57+
[#149537]: https://github.com/cockroachdb/cockroach/pull/149537

src/current/v24.3/ldap-authentication.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ summary: Learn how to configure CockroachDB for user authentication using LDAP-c
44
toc: true
55
---
66

7-
CockroachDB supports authentication and authorization using LDAP-compatible directory services, such as Active Directory and Microsoft Entra ID. This allows you to integrate your cluster with your organization's existing identity infrastructure for centralized user management and access control.
7+
{{site.data.alerts.callout_info}}
8+
{% include feature-phases/preview.md %}
9+
{{site.data.alerts.end}}
10+
11+
CockroachDB supports authentication and authorization using systems compatible with the Lightweight Directory Access Protocol (LDAP), such as Active Directory and Microsoft Entra ID. This allows you to integrate your cluster with your organization's existing identity infrastructure for centralized user management and access control.
812

9-
This page describes how to configure CockroachDB user authentication using LDAP. You can additionally configure CockroachDB to use the same directory service for user [authorization]({% link v24.3/ldap-authorization.md %}) (role-based access control), which assigns CockroachDB roles to users based on their group memberships in the directory.
13+
This page describes how to configure CockroachDB user authentication using LDAP. You can additionally configure CockroachDB to use the same directory service for user [authorization]({% link {{ page.version.version }}/ldap-authorization.md %}) (role-based access control), which assigns CockroachDB roles to users based on their group memberships in the directory.
1014

1115
## Overview
1216

@@ -21,12 +25,16 @@ While LDAP configuration is cluster-specific, each request to authenticate a use
2125
- If a matching record was found, the cluster attempts to verify the user's identity through another LDAP request, this time using the credentials (username and password) provided by that user.
2226
- If this LDAP bind operation succeeds, the user is authenticated to the CockroachDB cluster.
2327
1. Authorize the user (optional)
24-
- If [LDAP authorization]({% link v24.3/ldap-authorization.md %}) is also enabled, an additional request is sent to retrieve the groups to which the user is assigned, using configurable criteria.
28+
- If [LDAP authorization]({% link {{ page.version.version }}/ldap-authorization.md %}) is also enabled, the cluster sends an additional request to retrieve the groups to which the user is assigned, using configurable criteria.
2529
- If group memberships are found, any existing CockroachDB roles that match these group names are assigned to the user.
2630

2731
These requests use a node's existing connection to the LDAP server, if one is open. Otherwise, the node establishes a new connection. The connection remains open for handling additional LDAP requests until it is closed by the LDAP server, based on its timeout setting.
2832

29-
Because CockroachDB maintains no more than one LDAP connection per node, for a cluster with `n` nodes, you can expect up to `n` concurrent LDAP connections.
33+
Because CockroachDB maintains no more than one LDAP connection per node, for a cluster with `n` nodes, you can expect up to `n` concurrent LDAP connections.
34+
35+
{{site.data.alerts.callout_info}}
36+
LDAP authentication cannot be used for the `root` user or other [reserved identities]({% link {{ page.version.version }}/security-reference/authorization.md %}#reserved-identities). You must manage credentials for `root` separately using password authentication to ensure continuous administrative access regardless of LDAP availability.
37+
{{site.data.alerts.end}}
3038

3139
## Configuration
3240

@@ -96,17 +104,15 @@ SET CLUSTER SETTING server.ldap_authentication.client.tls_key = '<PEM_ENCODED_KE
96104

97105
### Step 4: Sync database users
98106

107+
Before LDAP authentication can be enabled for a user, you must create the username directly in CockroachDB. You will need to establish an automated method for keeping users in sync with the directory server, creating and dropping them as needed.
108+
99109
{{site.data.alerts.callout_info}}
100-
LDAP authentication cannot be used for the `root` user or other [reserved identities]({% link {{ page.version.version }}/security-reference/authorization.md %}#reserved-identities). Credentials for `root` must be managed separately using password authentication to ensure continuous administrative access regardless of LDAP availability.
110+
As of v25.3, CockroachDB can automatically provision users during their first successful LDAP authentication. Refer to the [latest version]({% link {{ site.versions.stable }}/ldap-authentication.md %}) of this page.
101111
{{site.data.alerts.end}}
102112

103-
Before LDAP authentication can be used for a user, the username must be created directly in CockroachDB. You will need to establish an automated method for keeping users in sync with the directory server, creating and dropping them as needed.
104-
105113
For Active Directory deployments, the CockroachDB username can typically be set to match the `sAMAccountName` field from the `user` object. This field name would need to be specified in the HBA configuration using `ldapsearchattribute=sAMAccountName`.
106114

107-
{{site.data.alerts.callout_info}}
108115
SQL usernames must comply with CockroachDB's [username requirements]({% link {{ page.version.version }}/create-user.md %}#user-names). Ensure that the values in the field you are using for `ldapsearchattribute` meet these requirements.
109-
{{site.data.alerts.end}}
110116

111117
To create a single user:
112118

@@ -196,4 +202,4 @@ Potential issues to investigate may pertain to:
196202
2. Use LDAPS (LDAP over TLS) in production environments.
197203
3. Use a restricted service account for directory searches.
198204
4. Regularly audit LDAP group memberships.
199-
5. Monitor authentication logs for unusual patterns.
205+
5. Monitor authentication logs for unusual patterns.

src/current/v24.3/ldap-authorization.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ summary: Learn how to configure role-based access control (authorization) using
44
toc: true
55
---
66

7-
You can configure your cluster to assign [roles]({% link {{ page.version.version }}/ldap-authentication.md %}) based on a user's group membership in an LDAP service, such as Active Directory or Microsoft Entra ID.
7+
{{site.data.alerts.callout_info}}
8+
{% include feature-phases/preview.md %}
9+
{{site.data.alerts.end}}
10+
11+
If you manage users through a service compatible with the Lightweight Directory Access Protocol (LDAP), such as Active Directory or Microsoft Entra ID, you can configure CockroachDB to automatically assign [roles]({% link {{ page.version.version }}/security-reference/authorization.md %}) to users based on LDAP group memberships, simplifying access control.
812

913
When enabled:
1014

@@ -14,15 +18,15 @@ When enabled:
1418

1519
## Prerequisites
1620

17-
- Enable [LDAP Authentication]({% link {{ page.version.version }}/ldap-authentication.md %}).
21+
- Enable [LDAP authentication]({% link {{ page.version.version }}/ldap-authentication.md %}).
1822

1923
## Configuration
2024

2125
Before you begin, it may be useful to enable authentication logging, which can help you confirm sucessful configuration or troubleshoot issues. For details, refer to [Troubleshooting](#troubleshooting).
2226

2327
### Step 1: Enable LDAP Authorization
2428

25-
Add the `ldapgrouplistfilter` parameter to the HBA configuration that you enabled for [LDAP Authentication]({% link {{ page.version.version }}/ldap-authentication.md %}). The configuration will include two important LDAP filters:
29+
Add the `ldapgrouplistfilter` parameter to the HBA configuration that you enabled for [LDAP authentication]({% link {{ page.version.version }}/ldap-authentication.md %}). The configuration will include two important LDAP filters:
2630

2731
1. `ldapsearchfilter`: Determines which users can authenticate
2832
2. `ldapgrouplistfilter`: Defines which groups should be considered for authorization
@@ -131,7 +135,7 @@ Potential issues to investigate may pertain to:
131135
## Security Considerations
132136

133137
1. Always keep a backup authentication method (like password) for administrative users.
134-
2. Use LDAPS (LDAP over TLS) in production environments.
135-
3. Use a restricted service account for directory searches.
136-
4. Regularly audit LDAP group memberships.
137-
5. Monitor authentication logs for unusual patterns.
138+
1. Use LDAPS (LDAP over TLS) in production environments.
139+
1. Use a restricted service account for directory searches.
140+
1. Regularly audit LDAP group memberships.
141+
1. Monitor authentication logs for unusual patterns.

src/current/v25.1/ldap-authentication.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ summary: Learn how to configure CockroachDB for user authentication using LDAP-c
44
toc: true
55
---
66

7-
CockroachDB supports authentication and authorization using LDAP-compatible directory services, such as Active Directory and Microsoft Entra ID. This allows you to integrate your cluster with your organization's existing identity infrastructure for centralized user management and access control.
7+
{{site.data.alerts.callout_info}}
8+
{% include feature-phases/preview.md %}
9+
{{site.data.alerts.end}}
10+
11+
CockroachDB supports authentication and authorization using systems compatible with the Lightweight Directory Access Protocol (LDAP), such as Active Directory and Microsoft Entra ID. This allows you to integrate your cluster with your organization's existing identity infrastructure for centralized user management and access control.
812

9-
This page describes how to configure CockroachDB user authentication using LDAP. You can additionally configure CockroachDB to use the same directory service for user [authorization]({% link v24.3/ldap-authorization.md %}) (role-based access control), which assigns CockroachDB roles to users based on their group memberships in the directory.
13+
This page describes how to configure CockroachDB user authentication using LDAP. You can additionally configure CockroachDB to use the same directory service for user [authorization]({% link {{ page.version.version }}/ldap-authorization.md %}) (role-based access control), which assigns CockroachDB roles to users based on their group memberships in the directory.
1014

1115
## Overview
1216

@@ -21,12 +25,16 @@ While LDAP configuration is cluster-specific, each request to authenticate a use
2125
- If a matching record was found, the cluster attempts to verify the user's identity through another LDAP request, this time using the credentials (username and password) provided by that user.
2226
- If this LDAP bind operation succeeds, the user is authenticated to the CockroachDB cluster.
2327
1. Authorize the user (optional)
24-
- If [LDAP authorization]({% link v24.3/ldap-authorization.md %}) is also enabled, an additional request is sent to retrieve the groups to which the user is assigned, using configurable criteria.
28+
- If [LDAP authorization]({% link {{ page.version.version }}/ldap-authorization.md %}) is also enabled, the cluster sends an additional request to retrieve the groups to which the user is assigned, using configurable criteria.
2529
- If group memberships are found, any existing CockroachDB roles that match these group names are assigned to the user.
2630

2731
These requests use a node's existing connection to the LDAP server, if one is open. Otherwise, the node establishes a new connection. The connection remains open for handling additional LDAP requests until it is closed by the LDAP server, based on its timeout setting.
2832

29-
Because CockroachDB maintains no more than one LDAP connection per node, for a cluster with `n` nodes, you can expect up to `n` concurrent LDAP connections.
33+
Because CockroachDB maintains no more than one LDAP connection per node, for a cluster with `n` nodes, you can expect up to `n` concurrent LDAP connections.
34+
35+
{{site.data.alerts.callout_info}}
36+
LDAP authentication cannot be used for the `root` user or other [reserved identities]({% link {{ page.version.version }}/security-reference/authorization.md %}#reserved-identities). You must manage credentials for `root` separately using password authentication to ensure continuous administrative access regardless of LDAP availability.
37+
{{site.data.alerts.end}}
3038

3139
## Configuration
3240

@@ -96,17 +104,15 @@ SET CLUSTER SETTING server.ldap_authentication.client.tls_key = '<PEM_ENCODED_KE
96104

97105
### Step 4: Sync database users
98106

107+
Before LDAP authentication can be enabled for a user, you must create the username directly in CockroachDB. You will need to establish an automated method for keeping users in sync with the directory server, creating and dropping them as needed.
108+
99109
{{site.data.alerts.callout_info}}
100-
LDAP authentication cannot be used for the `root` user or other [reserved identities]({% link {{ page.version.version }}/security-reference/authorization.md %}#reserved-identities). Credentials for `root` must be managed separately using password authentication to ensure continuous administrative access regardless of LDAP availability.
110+
As of v25.3, CockroachDB can automatically provision users during their first successful LDAP authentication. Refer to the [latest version]({% link {{ site.versions.stable }}/ldap-authentication.md %}) of this page.
101111
{{site.data.alerts.end}}
102112

103-
Before LDAP authentication can be used for a user, the username must be created directly in CockroachDB. You will need to establish an automated method for keeping users in sync with the directory server, creating and dropping them as needed.
104-
105113
For Active Directory deployments, the CockroachDB username can typically be set to match the `sAMAccountName` field from the `user` object. This field name would need to be specified in the HBA configuration using `ldapsearchattribute=sAMAccountName`.
106114

107-
{{site.data.alerts.callout_info}}
108115
SQL usernames must comply with CockroachDB's [username requirements]({% link {{ page.version.version }}/create-user.md %}#user-names). Ensure that the values in the field you are using for `ldapsearchattribute` meet these requirements.
109-
{{site.data.alerts.end}}
110116

111117
To create a single user:
112118

@@ -196,4 +202,4 @@ Potential issues to investigate may pertain to:
196202
2. Use LDAPS (LDAP over TLS) in production environments.
197203
3. Use a restricted service account for directory searches.
198204
4. Regularly audit LDAP group memberships.
199-
5. Monitor authentication logs for unusual patterns.
205+
5. Monitor authentication logs for unusual patterns.

src/current/v25.1/ldap-authorization.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ summary: Learn how to configure role-based access control (authorization) using
44
toc: true
55
---
66

7-
You can configure your cluster to assign [roles]({% link {{ page.version.version }}/ldap-authentication.md %}) based on a user's group membership in an LDAP service, such as Active Directory or Microsoft Entra ID.
7+
{{site.data.alerts.callout_info}}
8+
{% include feature-phases/preview.md %}
9+
{{site.data.alerts.end}}
10+
11+
If you manage users through a service compatible with the Lightweight Directory Access Protocol (LDAP), such as Active Directory or Microsoft Entra ID, you can configure CockroachDB to automatically assign [roles]({% link {{ page.version.version }}/security-reference/authorization.md %}) to users based on LDAP group memberships, simplifying access control.
812

913
When enabled:
1014

@@ -14,15 +18,15 @@ When enabled:
1418

1519
## Prerequisites
1620

17-
- Enable [LDAP Authentication]({% link {{ page.version.version }}/ldap-authentication.md %}).
21+
- Enable [LDAP authentication]({% link {{ page.version.version }}/ldap-authentication.md %}).
1822

1923
## Configuration
2024

2125
Before you begin, it may be useful to enable authentication logging, which can help you confirm sucessful configuration or troubleshoot issues. For details, refer to [Troubleshooting](#troubleshooting).
2226

2327
### Step 1: Enable LDAP Authorization
2428

25-
Add the `ldapgrouplistfilter` parameter to the HBA configuration that you enabled for [LDAP Authentication]({% link {{ page.version.version }}/ldap-authentication.md %}). The configuration will include two important LDAP filters:
29+
Add the `ldapgrouplistfilter` parameter to the HBA configuration that you enabled for [LDAP authentication]({% link {{ page.version.version }}/ldap-authentication.md %}). The configuration will include two important LDAP filters:
2630

2731
1. `ldapsearchfilter`: Determines which users can authenticate
2832
2. `ldapgrouplistfilter`: Defines which groups should be considered for authorization
@@ -131,7 +135,7 @@ Potential issues to investigate may pertain to:
131135
## Security Considerations
132136

133137
1. Always keep a backup authentication method (like password) for administrative users.
134-
2. Use LDAPS (LDAP over TLS) in production environments.
135-
3. Use a restricted service account for directory searches.
136-
4. Regularly audit LDAP group memberships.
137-
5. Monitor authentication logs for unusual patterns.
138+
1. Use LDAPS (LDAP over TLS) in production environments.
139+
1. Use a restricted service account for directory searches.
140+
1. Regularly audit LDAP group memberships.
141+
1. Monitor authentication logs for unusual patterns.

0 commit comments

Comments
 (0)