# Get current username within a REST plugin

**URL:** <https://discuss.elastic.co/t/get-current-username-within-a-rest-plugin/212729>\
**Category:** Elasticsearch\
**Created:** [December 21, 2019, 9:13am UTC](https://discuss.elastic.co/t/get-current-username-within-a-rest-plugin/212729 "2019-12-21T09:13:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asfoor.hasan.m](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@asfoor.hasan.m](https://discuss.elastic.co/u/asfoor.hasan.m)\
**Post date:** [December 21, 2019, 9:13am UTC](https://discuss.elastic.co/t/get-current-username-within-a-rest-plugin/212729/1 "2019-12-21T09:13:52Z")

</div>

Greetings,

I am trying to create a custom search API that filters the records based on users. I am extending the BaseRestHandler and I need to get the current user name within the prepareRequest method. I appreciate help in this matter.

public class CustomSearchAction extends BaseRestHandler {

public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {  
}  
}

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 18, 2020, 9:18am UTC](https://discuss.elastic.co/t/get-current-username-within-a-rest-plugin/212729/2 "2020-01-18T09:18:57Z")

</div>

Closed on January 18, 2020, 9:18am UTC

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