# Handing over JWT to OpenSearch in requests using Spring Data for OpenSearch

**URL:** <https://forum.opensearch.org/t/handing-over-jwt-to-opensearch-in-requests-using-spring-data-for-opensearch/27216>\
**Category:** OpenSearch Client Libraries\
**Tags:** opensearch-java\
**Created:** [October 2, 2025, 4:12pm UTC](https://forum.opensearch.org/t/handing-over-jwt-to-opensearch-in-requests-using-spring-data-for-opensearch/27216 "2025-10-02T16:12:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.schuerger](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@thomas.schuerger](https://forum.opensearch.org/u/thomas.schuerger)\
**Post date:** [October 2, 2025, 4:12pm UTC](https://forum.opensearch.org/t/handing-over-jwt-to-opensearch-in-requests-using-spring-data-for-opensearch/27216/1 "2025-10-02T16:12:24Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser): OpenSearch 3.2.0, Spring Boot 3.4.x

**Describe the issue** :

I have a Spring Boot application where users authenticate with JWT using Spring Security. I want to hand over this JWT in the Authorization header to OpenSearch for all OpenSearch requests made for the current user.

How can this be done? I know that I can use a request interceptor to add headers to OpenSearch requests, but the threads that do the requests come from a thread pool and do not have access to the SecurityContextHolder to get the JWT. How can I make the JWT available to the threads doing the OpenSearch calls?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [December 1, 2025, 4:13pm UTC](https://forum.opensearch.org/t/handing-over-jwt-to-opensearch-in-requests-using-spring-data-for-opensearch/27216/2 "2025-12-01T16:13:07Z")

</div>

Closed on December 1, 2025, 4:13pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
