Skip to content

Commit

Permalink
Interim build fix for PluginSubject related changes (#4690)
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit a1c0c7b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Aug 29, 2024
1 parent 0e9737f commit fc22c89
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
import org.opensearch.http.HttpServerTransport;
import org.opensearch.http.HttpServerTransport.Dispatcher;
import org.opensearch.http.netty4.ssl.SecureNetty4HttpServerTransport;
import org.opensearch.identity.PluginSubject;
import org.opensearch.identity.Subject;
import org.opensearch.identity.noop.NoopSubject;
import org.opensearch.index.IndexModule;
Expand All @@ -117,6 +118,7 @@
import org.opensearch.plugins.ExtensionAwarePlugin;
import org.opensearch.plugins.IdentityPlugin;
import org.opensearch.plugins.MapperPlugin;
import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.SecureHttpTransportSettingsProvider;
import org.opensearch.plugins.SecureSettingsFactory;
import org.opensearch.plugins.SecureTransportSettingsProvider;
Expand Down Expand Up @@ -162,6 +164,7 @@
import org.opensearch.security.hasher.PasswordHasherFactory;
import org.opensearch.security.http.NonSslHttpServerTransport;
import org.opensearch.security.http.XFFResolver;
import org.opensearch.security.identity.NoopPluginSubject;
import org.opensearch.security.identity.SecurityTokenManager;
import org.opensearch.security.privileges.PrivilegesEvaluator;
import org.opensearch.security.privileges.PrivilegesInterceptor;
Expand Down Expand Up @@ -2100,7 +2103,7 @@ private static String handleKeyword(final String field) {
}

@Override
public Subject getSubject() {
public Subject getCurrentSubject() {
// Not supported
return new NoopSubject();
}
Expand All @@ -2110,6 +2113,11 @@ public SecurityTokenManager getTokenManager() {
return tokenManager;
}

@Override
public PluginSubject getPluginSubject(Plugin plugin) {
return new NoopPluginSubject(threadPool);

Check warning on line 2118 in src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java#L2118

Added line #L2118 was not covered by tests
}

@Override
public Optional<SecureSettingsFactory> getSecureSettingFactory(Settings settings) {
return Optional.of(new OpenSearchSecureSettingsFactory(threadPool, sks, sslExceptionHandler, securityRestHandler));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

package org.opensearch.security.identity;

import java.security.Principal;
import java.util.concurrent.Callable;

import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.identity.NamedPrincipal;
import org.opensearch.identity.PluginSubject;
import org.opensearch.threadpool.ThreadPool;

public class NoopPluginSubject implements PluginSubject {
private final ThreadPool threadPool;

public NoopPluginSubject(ThreadPool threadPool) {
super();
this.threadPool = threadPool;
}

Check warning on line 28 in src/main/java/org/opensearch/security/identity/NoopPluginSubject.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/security/identity/NoopPluginSubject.java#L26-L28

Added lines #L26 - L28 were not covered by tests

@Override
public Principal getPrincipal() {
return NamedPrincipal.UNAUTHENTICATED;

Check warning on line 32 in src/main/java/org/opensearch/security/identity/NoopPluginSubject.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/security/identity/NoopPluginSubject.java#L32

Added line #L32 was not covered by tests
}

@Override
public <T> T runAs(Callable<T> callable) throws Exception {
try (ThreadContext.StoredContext ctx = threadPool.getThreadContext().stashContext()) {
return callable.call();

Check warning on line 38 in src/main/java/org/opensearch/security/identity/NoopPluginSubject.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/security/identity/NoopPluginSubject.java#L37-L38

Added lines #L37 - L38 were not covered by tests
}
}
}

0 comments on commit fc22c89

Please sign in to comment.