Skip to content

Commit

Permalink
Interim build fix for PluginSubject related changes
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Aug 28, 2024
1 parent 359272e commit 2715e0b
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 @@ -109,6 +109,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 @@ -119,6 +120,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 @@ -164,6 +166,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 @@ -2102,7 +2105,7 @@ private static String handleKeyword(final String field) {
}

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

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

Check warning on line 2120 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#L2120

Added line #L2120 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 2715e0b

Please sign in to comment.