Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
ed593d5
CP-311020: Design for enabling ldaps for external auth
Jan 15, 2026
1370ecc
CP-309060: Domain CPU RRD3 metric - numa_node_nonaffine_vcpus
mg12 Jul 24, 2025
16d1c04
CP-309060: merge: upstream patch 0004-rrd3
mg12 Jan 19, 2026
a516359
xenopsd/xc: adapt claim_pages to new single numa node version (CP-53658)
lindig Oct 29, 2025
f1f7476
CP-53658: merge: upstream patch 0003-CP-53658-adapt-claim_pages-to-ve…
mg12 Jan 19, 2026
7153d5d
xenopsd-xc: do not try keep track of free memory when planning NUMA n…
psafont Jun 19, 2025
e535771
CA-411684: merge: upstream patch 0005-xenopsd-xc-do-not-try-keep-trac…
mg12 Jan 19, 2026
6f750b8
CP-54238: RRD4: rebase over rrdp_squeezed.ml
mg12 Jul 1, 2025
9f71728
CA-412929: work around a small amount of internal pages in unclaimed …
mg12 Jul 1, 2025
ef10c4f
CP-310822: RRD4 :link Xenctrlext in rrdp-squeezed
mg12 Dec 10, 2025
0ec433b
CP-53238: merge: upstream patch 0005-rrd4
mg12 Jan 19, 2026
e6e90d6
Update datamodel lifecycle
robhoes Jan 20, 2026
ea41b65
CP-53658: only use xc_domain_claim_pages_node if defined
mg12 Jan 20, 2026
80045e8
reformat code using latest ocamlformat 0.28.1
mg12 Jan 20, 2026
4eb2ca1
CP-310822: use only xenctrlext
mg12 Jan 20, 2026
d73437c
CA-422713: XSI-2105: Pool.join failed due to AD status corrupt
Jan 13, 2026
8116cf5
CA-422713: XSI-2105: Pool.join failed due to AD status corrupt (#6832)
liulinC Jan 21, 2026
f05fa58
CP-310822: upstream patchqueue entries for XS9 (#6845)
robhoes Jan 21, 2026
be5420b
CA-419840 mark CD VBD as empty when its VDI is removed
lindig Jan 15, 2026
736eeb1
CA-419840 mark CD VBD as empty when its VDI is removed (#6840)
lindig Jan 21, 2026
aabf39f
CP-311102: Make migration timeouts configurable
robhoes Jan 20, 2026
7d4227b
CP-311102: Make migration timeouts configurable (#6846)
robhoes Jan 21, 2026
73a3ed3
datamodel_errors: generalize error for sr_suspend_space_insufficient
psafont Jan 21, 2026
fc74018
datamodel_errors: generalize error for sr_suspend_space_insufficient …
psafont Jan 21, 2026
ab74c88
qcow-stream-tool: Use tail-recursive functions in read_headers
last-genius Jan 21, 2026
b0a269e
qcow-stream-tool: Avoid stack overflows in read_headers (#6848)
last-genius Jan 22, 2026
40759d8
Don't depend on LANG for running tests
semarie Jan 21, 2026
61bec37
Don't depend on LANG for running tests (#6853)
psafont Jan 22, 2026
4db0de7
Fix -Wreturn-type warning in xenctrlext_stubs.c
lindig Jan 23, 2026
46d16f1
Fix -Wreturn-type warning in xenctrlext_stubs.c (#6859)
lindig Jan 23, 2026
ecb82f3
CP-311020: Design for enabling ldaps for external auth (#6837)
liulinC Jan 26, 2026
1b37d8e
CA-423213: Fix bundle URL construct
alexbrett Jan 24, 2026
4edb0d7
CA-423213: Fix bundle URL construct (#6860)
robhoes Jan 26, 2026
0333740
libs: Add token-bucket library
cplaursen Nov 11, 2025
bc1f240
rate-limit: Test token bucket
cplaursen Nov 27, 2025
48629c6
rate-limit: Implement bucket tables
cplaursen Nov 27, 2025
644c023
rate-limit: Create bucket table from xapi globs
cplaursen Nov 28, 2025
65f4d96
xapi: Add rate limiting to do_dispatch
cplaursen Nov 28, 2025
19f2cce
xapi rate limiting: Add logging
cplaursen Dec 1, 2025
d8746e0
rate_limit: Add rate limiter to xapi initialisation
cplaursen Dec 1, 2025
79eb936
Rate limiting: Improve token_bucket documentation
cplaursen Dec 1, 2025
3b26a1f
Rate limiting: token buckets with zero or negative fill rate fail
cplaursen Dec 1, 2025
508c9f3
rate-limit: Write unit tests for bucket table
cplaursen Dec 2, 2025
13aa711
rate-limit: Minor fixes to bucket table
cplaursen Dec 2, 2025
e3e5a40
rate-limit: Add readers-writer lock to bucket table
cplaursen Dec 4, 2025
dd13952
rate-limit: Handle rate limited requests in FIFO queue
cplaursen Dec 4, 2025
5eab869
rate-limit: Replace readers-writer lock with atomic Map
cplaursen Dec 5, 2025
5ff1a3b
rate-limit: Clarify token bucket creation docs
cplaursen Dec 5, 2025
07ee55b
idl: Add Rate_limit datamodel
cplaursen Dec 2, 2025
bf63f55
xapi-cli-server: Add rate limit CLI operations
cplaursen Dec 3, 2025
8a789ea
token_bucket: replace mutex with lock-free atomics
cplaursen Dec 2, 2025
ede7f9f
xapi_rate_limit: Replace xapi_globs support with datamodel
cplaursen Dec 8, 2025
7105c24
xapi_http: Add rate limiting to all handlers
cplaursen Dec 8, 2025
8f6f704
rate-limit: Process requests on original thread
cplaursen Dec 16, 2025
7f7dc14
Add logging to bucket tables
cplaursen Dec 11, 2025
bbdeeb1
xapi_http: Fix rate limiting wrapper
cplaursen Dec 11, 2025
5f3846c
rate-limit: Bypass rate limiting if user agent not registered
cplaursen Dec 12, 2025
804ad21
rate-limit: Prevent possible double locks when rate limiting
cplaursen Dec 12, 2025
e25cd3f
xapi-http: Don't rate limit handlers in the custom rate limit list
cplaursen Dec 12, 2025
7b4603f
xe: Add rate limit operations
cplaursen Dec 15, 2025
9a4a841
rate-limit: Fix names in records.ml
cplaursen Dec 15, 2025
cd49421
rate-limit: Return receipt immediately for async requests
cplaursen Dec 15, 2025
2a33b48
xe: Add rate-limit-destroy operation
cplaursen Dec 15, 2025
1e4a0ea
rate-limit: Adjust token costs of RPC calls
cplaursen Jan 5, 2026
6e63e7f
bucket_table: Use with_lock for mutexes
cplaursen Jan 6, 2026
0738d84
Bucket_table: convert to functor parameterised by key type
cplaursen Jan 16, 2026
fc6d32a
rate-limit: Add host_ip option to rate limiter
cplaursen Jan 16, 2026
ee5bd3e
xapi-cli-server: Add host-ip and user-agent to xe rate limit CLI
cplaursen Jan 19, 2026
97eacc8
bucket-table: Hard-code key data structure
cplaursen Jan 22, 2026
48c8f27
rate-limit: Add lru-cache module
cplaursen Jan 22, 2026
01693b0
rate-limit: Implement wildcard indexing for clients
cplaursen Jan 22, 2026
4abba85
xapi: Only rate limit external requests
cplaursen Jan 23, 2026
12d965a
quicktest: Add test for rate limit
cplaursen Jan 23, 2026
e032159
quicktest: Register the xapi_rate_limit test
cplaursen Jan 23, 2026
59da124
quicktest_rate_limit: Add proper load testing
cplaursen Jan 23, 2026
502dd0d
rate-limit: Add debugging when a request is throttled
cplaursen Jan 23, 2026
92ed336
quicktest: Check whether rate limiting delays fall within the expecte…
cplaursen Jan 26, 2026
032a086
rate-limit: Add post_cli to custom rate limit actions
cplaursen Jan 28, 2026
344711b
rate-limit: Update token costs to be more realistic
cplaursen Jan 29, 2026
5f56db5
quicktest: fix formatting on rate limit test
cplaursen Feb 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
323 changes: 323 additions & 0 deletions doc/content/design/external-auth-ldaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,323 @@
---
title: Secure LDAP (LDAPS) Support for External Authentication
layout: default
design_doc: true
revision: 1
status: draft
---

## Terminology

| Term | Meaning |
|------|---------|
| AD | Windows Active Directory |
| samba/winbind | Client used in xapi to talk to AD |
| DC | Windows AD domain controller |
| ldap/ldaps | Lightweight Directory Access Protocol / over SSL |
| Joining host | The host joining to a pool |

## 1. Background

To integrate XenServer with AD, XenServer performs LDAP queries in the following use cases:

- **Enable external authentication/Join domain**: Samba LDAP queries DC details
- **Session revalidation**: xapi queries user details (e.g., whether user is still valid, password expired, etc.) to decide whether to destroy a session

Currently XenServer uses plain LDAP queries, which is a concern for some enterprise customers.

## 2. Xapi Database

### 2.1 External Auth Configuration

External auth details are stored in the `host` (table) → `external_auth_configuration` (field). For example:

```
external_auth_configuration: {
domain: xenrt16718.local,
user: Administrator,
workgroup: XENRTXENRT16718,
netbios_name: genus-35-103d,
machine_pwd_last_change_time: 1767508709
}
```

A new field `ldaps` (bool, optional) will be added to `external_auth_configuration` field to state whether LDAPS should be used instead of LDAP. If not set, LDAP will be used for backward compatibility.

So the field will look like:

```
external_auth_configuration: {
domain: xenrt16718.local,
user: Administrator,
workgroup: XENRTXENRT16718,
netbios_name: genus-35-103d,
machine_pwd_last_change_time: 1767508709,
ldaps: true
}
```

### 2.2 Certificate

To enforce security, if customer uses self-signed certificate, they need to upload the root CA certificate to XenServer, so XenServer can verify the certificate/public key used talking to DC for LDAPS.

The [trusted-certificates.md](https://github.com/xapi-project/xen-api/blob/master/doc/content/design/trusted-certificates.md) design enhanced the `Certificate` table and introduced a new field `purpose` for security, which limits the certificate only for specific purpose. `ldaps` will be added to `purpose` field as a value for LDAPS.

## 3. Interfaces

### 3.1 pool.enable_external_auth

To enable external auth, the current API arguments are as follows:

- `pool` (Ref _pool): The pool whose external authentication should be enabled
- `config` (Map (String, String)): A list of key-values containing the configuration data
- `service_name` (String): The name of the service
- `auth_type` (String): The type of authentication (e.g., AD for Active Directory)

For example:

```bash
xe pool-enable-external-auth uuid=<uuid> auth-type=AD service-name=<domain> config:user=<user> config:pass=<pwd>
```

This API signature does not change. Regarding the config map, one new option is added:

- `config:ldaps`: whether LDAPS is required, default to `false`
- Set `client ldap sasl wrapping` to `ldaps` if true, `seal` otherwise
- This item will be stored in database in section 2.1

Given `ldaps` default to `false`, this feature is **NOT** enabled until explicitly set.

### 3.2 Set/Get Pool LDAPS Status

#### 3.2.1 pool.external_auth_set_ldaps

User can specify LDAPS during join domain as in 3.1.

For the existing joined domain, user can switch between LDAP and LDAPS with this new API. Args as follows:

- `pool` (Ref _pool): pool to set LDAPS
- `ldaps` (Bool): whether LDAPS is required

This API will set the `ldaps` in database (Refer to 2.1).

This API performs following sanity check and rejects update if check fails:

- AD has already been enabled
- Find proper certificate (Refer to 4.1 for the details)
- Do a `ldaps` query to embedded user `krbtgt` for the joined domain

**Note:**
- This API allow en-entry for debug purpose
- Will not do the LDAPS query on the trusted domains, as xapi does not have trusted domain details
- The joined domain likely has multiple DCs. LDAPS query tries every DC of the domain. Check pass if LDAPS query succeeds on any DC of the domain. This implies iterate and locate a DC supporting LDAPS (with proper certificate trust setup) before LDAPS query. However, this does not introduce performance problems as the LDAPS query happens in backend and refreshes result into XAPI DB
- Pool coordinator dispatches this API request to every host, and only succeeds if all hosts pass the check
- This API needs to be synced with other APIs. For example, `authenticate_username_password` should fail if this API is performing checking and configuration

This API will refresh `winbind` configuration (Refer to 4.1).

So following xe command can be used to switch between LDAP and LDAPS:

```bash
xe pool-external-auth-set-ldaps uuid=<uuid> ldaps=<true|false>
```

#### 3.2.2 Get Pool LDAPS Status

xapi generates a get message for each field automatically. To query the LDAPS status, client only needs to query the get method of `host` (class) → `external-auth-configuration` (field), and parse the result. The example as follows:

```bash
xe host-param-get uuid=<uuid> param-name=external-auth-configuration
```

### 3.3 Install Certificate

If the certificate for LDAPS in DC is signed by a private CA (vs a trusted public CA), user needs to import their Root or Intermediate CA certificate into XenServer.

`pool.install_trusted_certificate` can install the certificate with following parameters, refer to [trusted-certificates.md](https://github.com/xapi-project/xen-api/blob/master/doc/content/design/trusted-certificates.md) for the details:

- `session` (ref session_id): reference to a valid session
- `self` (ref Pool): reference to the pool
- `ca` (boolean): should always be `true` for `ldaps`. xapi should reject this CA otherwise
- `cert` (string): the trusted certificate in PEM format
- `purpose` (string list): the purposes of this cert. It can be one of following:
- contain `ldaps` if for specific this specific purpose
- empty set, thus would take as general purpose CA. It will be used for `ldaps` if no `ldaps` specific purpose found

**Note:** If the DCs (of joining domain and trusted domain in use) are signed by different CAs, all the CAs need to be uploaded to XenServer.

## 4. Configuration Item

To enforce LDAPS, following are required:

- Samba needs to be updated to 4.21+ (Already done)
- LDAPS needs to be enabled in smb.conf

### 4.1 Samba Configuration

#### 4.1.1 smb.conf

To enforce LDAPS, xapi just passthrough the configuration to winbind. Following configuration needs to be updated to `/etc/samba/smb.conf`, details refer to [smb.conf](https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html):

```ini
client ldap sasl wrapping = <ldaps | seal>
tls verify peer = ca_and_name_if_available
tls trust system cas = yes
tls cafile = /etc/trusted-certs/ca-bundle-[ldaps|general].pem
```

- Switch between `ldap` and `ldaps` will flip `client ldap sasl wrapping` between `seal` and `ldaps`
- `tls cafile` points to a CA bundle used to verify DC certs. Details refer to 4.1.2

#### 4.1.2 Certificate Selection

This design is following [trusted-certificates.md](https://github.com/xapi-project/xen-api/blob/master/doc/content/design/trusted-certificates.md):

- Use `/etc/trusted-certs/ca-bundle-ldaps.pem` if exists
- Fall back to `/etc/trusted-certs/ca-bundle-general.pem` if exists and previous not match
- Report error if none of above match

**Note:** The selection/configuration is only refreshed on following cases:

- xapi (re)start
- `pool.external_auth_set_ldaps` API
- (Re)join domain

### 4.2 Xapi Configuration

#### 4.2.1 winbind-tls-verify-peer

For security, xapi asks winbind to verify CA certificate. `ca_and_name_if_available` is the default.

However, user may want to disable this verification for debug purpose.

`winbind-tls-verify-peer` is introduced for xapi configuration, and the possible values are `no_check`, `ca_only`, `ca_and_name_if_available`, `ca_and_name` and `as_strict_as_possible`.
The configured value will override `tls verify peer` value in xapi generated samba configuration. Refer to [smb.conf](https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html) for the details.


**Note:** This item is not intended for public documentation. This is only for debug purpose, or system tuning for specific scenarios from engineering/support team.

#### 4.2.2 ad-warning-message-interval

xapi sends warning message to user with this interval on LDAP query failure. Default to 1 week. Refer to section "Session revalidate" for the details.

## 5. Session Revalidate

xapi LDAP queries domain user status (if user has been added to manage XenServer) at configurable interval, and destroys the session created by domain user if user no longer in healthy status.

However, the LDAP query may fail due to various issues as follows:

- Temporary network issues
- CA certificate is not properly configured, or expired, etc.

Instead of destroying user session for stability, a warning message will be sent to user with the details at configurable interval `ad-warning-message-interval`.

- If no LDAP error, do nothing
- If error happens, send the warning message if:
- first time see the error through xapi start up (so no need to persist last send time) or
- `current_time - last_sent_time > winbind_warning_message_interval`

The message is defined as follows:
- name: AD_DC_LDAP_CHECK
- priority: Warning
- cls: `Host
- Body: LDAP(S) query check to `<DC>` of `<domain>` failed from `<host>` of `<pool>`

Note:
- The backend session revalidate check only performs on pool coordinator, thus the backend LDAP(S) query check only on coordinator
- `external_auth_set_ldaps` perform LDAP(S) query check on every host
- All previous AD_DC_LDAP_CHECK warning of a host will be cleaned on a successful LDAP(s) query from that host

## 6. Pool Join/Leave

### 6.1 pool.join

#### 6.1.1 AD Pre-checks

Currently the pool.join pre-check checks the following:

- `external_auth_type`: whether joined AD
- `external_auth_service_name`: whether joined the same domain

The pre-check is good enough, no matter whether `ldaps` is in use, as this ensures host can talk to AD. There are following cases:

- pool with AD, joining host with same AD: check pass as before this design
- pool without AD, joining host without AD: check pass as before this design
- pool without AD, joining host with AD: check failed as before this design
- pool with AD, joining host without AD:
- LDAPS not enabled: joining host needs to join to same AD as before this design
- LDAPS enabled: joining host needs to enable AD without certificate check, details refer to 6.1.2

#### 6.1.2 Join Host to Pool with LDAPS Enabled

When joining a host without AD to a pool with LDAPS enabled, the host may not have the (CA) certificate for the domain. It can be trivial to enforce customer to upload the CA certificate to every joining host, thus client would help to orchestrate certificates.

The workflow:

~~~mermaid

sequenceDiagram
participant user as User
participant client as Client
participant join as Joining host
participant coor as Pool Coordinator
participant dc as AD/DC

user->>client: pool.join
Note over client: precheck
alt precheck failed
client-->>user: precheck failed
end

Note over client,coor: sync all ldaps certs
client->>coor: pool.download_trusted_certificate
coor-->>client:
client->>join: pool.install_trusted_certificate
join-->>client:

user->>client: join domain username/password
client->>join: join domain username/password
join->>dc: join domain
dc-->>join:
join-->>client:

client->>join: pool.join
Note over join,coor: join pool ops<br/>certs sync
join-->>client:
client-->>user: pool.join succeed

~~~

**Detailed Steps:**

1. Client find proper `ldaps certs` from pool coordinator as `certs_pool`
- a. find all certs `ldaps in purpose`
- b. if no LDAPS certs, find all `general` certs
2. Client find all certs in joining host as `certs_joining_host`
3. Client identify the certs needs to be synced to joining host as `certs_to_sync = certs_pool - certs_joining_host` (certs in `certs_pool`, but not in `certs_joining_host`), the certs fingerprint should be used to identify the certs
4. Client download all `certs_to_sync`, `pool.download_trusted_certificate` from coordinator
5. Client upload all certs to joining pool, `pool.install_trusted_certificate` to joining pool, with the same purpose
6. Client trigger `pool.join` again with domain username and password
7. After pool.join:
- If pool.join failed, Client call `pool.uninstall_trusted_certificate` on joining host to revert the certs
- If pool.join succeed, do nothing as pool.join would sync the certs anyway

### 6.2 pool.leave

`pool.disable_external_auth` is called during pool leave, thus the `ldaps` status is cleaned.

This design does not change it.

## 7. Telemetry Support

### 7.1 External Auth Enabled

`host` (table) → `external_auth_type` (field) = `AD`

### 7.2 LDAPS Enabled

`host` (table) → `external_auth_configuration` (field) → `ldaps` (key) = `true`

## References

- [trusted-certificates.md](https://github.com/xapi-project/xen-api/blob/master/doc/content/design/trusted-certificates.md)
- [Samba smb.conf manual](https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html)
7 changes: 5 additions & 2 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
(ocamlopt_flags (:standard -g -p -w -39))
(flags (:standard -w -39))
)
(dev (flags (:standard -g -w -39)))
(dev
(flags (:standard -g -w -39))
(env-vars (LANG C)))
(release
(flags (:standard -w -39-6@5))
(env-vars (ALCOTEST_COMPACT 1))
(env-vars (ALCOTEST_COMPACT 1)
(LANG C))
)
)

Expand Down
7 changes: 7 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
(name tgroup)
(depends xapi-log xapi-stdext-unix))

(package
(name rate-limit)
(synopsis "Simple token bucket-based rate-limiting")
(depends
(ocaml (>= 4.12))
xapi-log xapi-stdext-unix))

(package
(name xml-light2))

Expand Down
7 changes: 7 additions & 0 deletions ocaml/idl/datamodel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10545,6 +10545,7 @@ let all_system =
; Datamodel_vm_group.t
; Datamodel_host_driver.t
; Datamodel_driver_variant.t
; Datamodel_rate_limit.t
]

(* If the relation is one-to-many, the "many" nodes (one edge each) must come before the "one" node (many edges) *)
Expand Down Expand Up @@ -10796,6 +10797,7 @@ let expose_get_all_messages_for =
; _observer
; _host_driver
; _driver_variant
; _rate_limit
]

let no_task_id_for = [_task; (* _alert; *) _event]
Expand Down Expand Up @@ -11152,6 +11154,11 @@ let http_actions =
; ("put_bundle", (Put, Constants.put_bundle_uri, true, [], _R_POOL_OP, []))
]

(* Actions that incorporate the rate limiter from Xapi_rate_limiting within their handler
For now, just RPC calls *)
let custom_rate_limit_http_actions =
["post_root"; "post_RPC2"; "post_jsonrpc"; "post_cli"]

(* these public http actions will NOT be checked by RBAC *)
(* they are meant to be used in exceptional cases where RBAC is already *)
(* checked inside them, such as in the XMLRPC (API) calls *)
Expand Down
4 changes: 3 additions & 1 deletion ocaml/idl/datamodel_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Datamodel_roles
to leave a gap for potential hotfixes needing to increment the schema version.*)
let schema_major_vsn = 5

let schema_minor_vsn = 793
let schema_minor_vsn = 794

(* Historical schema versions just in case this is useful later *)
let rio_schema_major_vsn = 5
Expand Down Expand Up @@ -315,6 +315,8 @@ let _host_driver = "Host_driver"

let _driver_variant = "Driver_variant"

let _rate_limit = "Rate_limit"

let update_guidances =
Enum
( "update_guidances"
Expand Down
Loading
Loading