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

Introduce new API _plugins/_security/ssl/certs #1841

Merged
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 @@ -18,11 +18,11 @@
import java.io.IOException;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -44,16 +44,18 @@
import org.opensearch.security.user.User;
import org.opensearch.threadpool.ThreadPool;

import static org.opensearch.security.dlic.rest.support.Utils.addRoutesPrefix;


/**
* Rest API action to get SSL certificate information related to http and transport encryption.
* Only super admin users are allowed to access this API.
* Currently this action serves GET request for _opendistro/_security/api/ssl/certs endpoint
* Currently this action serves GET request for _plugins/_security/api/ssl/certs endpoint
*/
public class SecuritySSLCertsInfoAction extends BaseRestHandler {
private static final List<Route> routes = Collections.singletonList(
new Route(Method.GET, "/_opendistro/_security/api/ssl/certs")
);
private static final List<Route> routes = addRoutesPrefix(ImmutableList.of(
new Route(Method.GET, "/ssl/certs")
));

private final Logger log = LogManager.getLogger(this.getClass());
private Settings settings;
Expand Down Expand Up @@ -82,7 +84,7 @@ public List<Route> routes() {
* GET request to fetch transport certificate details
*
* Sample request:
* GET _opendistro/_security/api/ssl/certs
* GET _plugins/_security/api/ssl/certs
*
* Sample response:
* {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import net.minidev.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import org.opensearch.common.settings.Settings;
import org.opensearch.security.ssl.util.SSLConfigConstants;
Expand All @@ -31,9 +33,24 @@
import org.opensearch.security.test.helper.file.FileHelper;
import org.opensearch.security.test.helper.rest.RestHelper;

import static org.opensearch.security.OpenSearchSecurityPlugin.LEGACY_OPENDISTRO_PREFIX;
import static org.opensearch.security.OpenSearchSecurityPlugin.PLUGINS_PREFIX;

@RunWith(Parameterized.class)
public class SecuritySSLCertsInfoActionTests extends SingleClusterTest {
private final String ENDPOINT;

public SecuritySSLCertsInfoActionTests(String endpoint){
ENDPOINT = endpoint;
}

private final String ENDPOINT = "_opendistro/_security/api/ssl/certs";
@Parameterized.Parameters
public static Iterable<String> endpoints() {
return ImmutableList.of(
LEGACY_OPENDISTRO_PREFIX + "/api/ssl/certs",
PLUGINS_PREFIX + "/api/ssl/certs"
);
}

private final List<Map<String, String>> NODE_CERT_DETAILS = ImmutableList.of(
ImmutableMap.of(
Expand Down