-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opensearch keystore used for key/truststore passwords (#20923)
* opensearch keystore used for key/truststore passwords * code cleanup * Add changelog * Added integration test for opensearch keystore cli * add `-x` to add OS keystore secrets, bypassing the prompt --------- Co-authored-by: Matthias Oesterheld <[email protected]>
- Loading branch information
1 parent
3a3cc4b
commit ec1fd11
Showing
11 changed files
with
168 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type = "c" | ||
message = "Data node: store keystore and truststore passwords in Opensearch keystore" | ||
|
||
issues = ["20926"] | ||
pulls = ["20923"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
data-node/src/main/java/org/graylog/datanode/configuration/variants/KeystoreContributor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
package org.graylog.datanode.configuration.variants; | ||
|
||
import java.util.Map; | ||
|
||
public interface KeystoreContributor { | ||
/** | ||
* @return collection of key-value pairs that should be added to the opensearch keystore (holding secrets) | ||
*/ | ||
Map<String, String> getKeystoreItems(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...de/src/test/java/org/graylog/datanode/opensearch/cli/OpensearchKeystoreCommandLineIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
package org.graylog.datanode.opensearch.cli; | ||
|
||
import jakarta.annotation.Nonnull; | ||
import org.assertj.core.api.Assertions; | ||
import org.graylog.datanode.OpensearchDistribution; | ||
import org.graylog.datanode.configuration.OpensearchArchitecture; | ||
import org.graylog.datanode.configuration.OpensearchDistributionProvider; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.net.URISyntaxException; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
class OpensearchKeystoreCommandLineIT { | ||
|
||
@Test | ||
void testKeystoreLifecycle(@TempDir Path tempDir) throws URISyntaxException { | ||
final OpensearchCli cli = createCli(tempDir); | ||
final String createdResponse = cli.keystore().create(); | ||
|
||
Assertions.assertThat(createdResponse).contains("Created opensearch keystore"); | ||
|
||
cli.keystore().add("s3.client.default.access_key", "foo"); | ||
cli.keystore().add("s3.client.default.secret_key", "bar"); | ||
|
||
final List<String> response = cli.keystore().list(); | ||
Assertions.assertThat(response) | ||
.hasSize(3) // two keys and one internal seed | ||
.contains("s3.client.default.access_key") | ||
.contains("s3.client.default.secret_key"); | ||
} | ||
|
||
private OpensearchCli createCli(Path tempDir) throws URISyntaxException { | ||
final Path binDirPath = detectOpensearchBinDir(); | ||
return new OpensearchCli(tempDir, binDirPath); | ||
} | ||
|
||
@Nonnull | ||
private Path detectOpensearchBinDir() throws URISyntaxException { | ||
final Path opensearchDistRoot = Path.of(getClass().getResource("/").toURI()).getParent().resolve("opensearch"); | ||
final OpensearchDistributionProvider distributionProvider = new OpensearchDistributionProvider(opensearchDistRoot, OpensearchArchitecture.fromOperatingSystem()); | ||
final OpensearchDistribution opensearchDistribution = distributionProvider.get(); | ||
return opensearchDistribution.getOpensearchBinDirPath(); | ||
} | ||
} |