Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Add javadoc about ThreadContextPermission for stashWithOrigin and stashAndMergeHeaders #15055

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ public Writeable captureAsWriteable() {
* For example, a user might not have permission to GET from the tasks index
* but the tasks API will perform a get on their behalf using this method
* if it can't find the task in memory.
*
* Usage of stashWithOrigin is guarded by a ThreadContextPermission. In order to use
* stashWithOrigin, the codebase needs to explicitly be granted permission in the JSM policy file.
*
* Add an entry in the grant portion of the policy file like this:
*
* permission org.opensearch.secure_sm.ThreadContextPermission "stashWithOrigin";
*/
public StoredContext stashWithOrigin(String origin) {
SecurityManager sm = System.getSecurityManager();
Expand All @@ -237,6 +244,13 @@ public StoredContext stashWithOrigin(String origin) {
* Removes the current context and resets a new context that contains a merge of the current headers and the given headers.
* The removed context can be restored when closing the returned {@link StoredContext}. The merge strategy is that headers
* that are already existing are preserved unless they are defaults.
*
* Usage of stashAndMergeHeaders is guarded by a ThreadContextPermission. In order to use
* stashAndMergeHeaders, the codebase needs to explicitly be granted permission in the JSM policy file.
*
* Add an entry in the grant portion of the policy file like this:
*
* permission org.opensearch.secure_sm.ThreadContextPermission "stashAndMergeHeaders";
*/
public StoredContext stashAndMergeHeaders(Map<String, String> headers) {
SecurityManager sm = System.getSecurityManager();
Expand Down
Loading