-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Elastic.Clients.Elasticsearch version:
9.1.2
Elasticsearch version:
9.1.2
.NET runtime version:
9.0.109
Operating system version:
macOS 15.5 (24F74)
Description of the problem including expected versus actual behavior:
In our multi-tenant environment, we need to pass authentication credentials (JWT tokens) per-request rather than per-client. We accomplish this using RequestDescriptors with the RequestConfiguration lambda method, specifically calling rc.Authentication() to set credentials.
This per-request authentication pattern works correctly for all other Elasticsearch methods
It fails specifically for Bulk* methods (including BulkAsync())
The issue occurs with both JWT and Basic authentication, indicating it's not token-type specific
This functionality worked in version 8.19.2 but is broken in 9.1.2
Steps to reproduce:
- Create instance of
ElasticsearchClient. - Run
BulkAsync()with per-request credentialsvar response = await client.BulkAsync(b => b .Index(IndexName) .IndexMany(documents) .RequestConfiguration(rc => rc.Authentication(new BasicAuthentication(_username, _password))) );
Expected behavior
Per-request authentication via RequestConfiguration should work consistently across all methods, including bulk operations.
Observed behavior
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/someindex/_bulk]","header":{"WWW-Authenticate":["Basic realm=\"security\", charset=\"UTF-8\"","ApiKey"]}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/someindex/_bulk]","header":{"WWW-Authenticate":["Basic realm=\"security\", charset=\"UTF-8\"","ApiKey"]}},"status":401}