Skip to content

Commit

Permalink
Removes lingering putPersistent calls
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Jan 20, 2025
1 parent ff56d24 commit c48a02b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ private <Request extends ActionRequest, Response extends ActionResponse> void ap
log.info("Transport auth in passive mode and no user found. Injecting default user");
user = User.DEFAULT_TRANSPORT_USER;
threadContext.putTransient(ConfigConstants.OPENDISTRO_SECURITY_USER, user);
threadContext.putPersistent(ConfigConstants.OPENDISTRO_SECURITY_USER, user);
} else {
log.error(
"No user found for "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.opensearch.index.engine.Engine;
import org.opensearch.index.shard.IndexingOperationListener;
import org.opensearch.security.auditlog.AuditLog;
import org.opensearch.security.auth.UserSubjectImpl;
import org.opensearch.security.support.ConfigConstants;
import org.opensearch.security.user.User;
import org.opensearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -87,8 +88,9 @@ public void postIndex(ShardId shardId, Engine.Index index, Engine.IndexResult re

String resourceId = index.id();

User user = (User) threadPool.getThreadContext().getPersistent(ConfigConstants.OPENDISTRO_SECURITY_USER);

final UserSubjectImpl userSubject = (UserSubjectImpl) threadPool.getThreadContext()
.getPersistent(ConfigConstants.OPENDISTRO_SECURITY_AUTHENTICATED_USER);
final User user = userSubject.getUser();
try {
ResourceSharing sharing = this.resourceSharingIndexHandler.indexResourceSharing(
resourceId,
Expand Down

0 comments on commit c48a02b

Please sign in to comment.