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

Interim build fix for PluginSubject related changes #4690

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
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 @@ -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 @@
}

@Override
public Subject getSubject() {
public Subject getCurrentSubject() {
// Not supported
return new NoopSubject();
}
Expand All @@ -2112,6 +2115,11 @@
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
}
}
}
Loading