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

[Backport 2.12] Fixes base64 encoded hardcoded admin credentials #1333

Merged
merged 1 commit into from
Feb 15, 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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ int endJmxPort = startJmxPort
integTest {
useCluster testClusters.leaderCluster
useCluster testClusters.followCluster
systemProperty "password", "admin" // setting it to `admin` explicitly since its a custom security setup

if(knnEnabled){
nonInputProperties.systemProperty('tests.knn_plugin_enabled', "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ import org.junit.After
import org.junit.AfterClass
import org.junit.Before
import org.junit.BeforeClass
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.security.KeyManagementException
import java.security.KeyStore
import java.security.KeyStoreException
import java.security.NoSuchAlgorithmException
import java.security.cert.CertificateException
import java.util.Base64
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicReference
import java.util.Collections
Expand Down Expand Up @@ -227,8 +229,10 @@ abstract class MultiClusterRestTestCase : OpenSearchTestCase() {
for ((key, value) in headers) {
defaultHeaders[i++] = BasicHeader(key, value)
}

val creds = System.getProperty("user", "admin") + ":" + System.getProperty("password", "myStrongPassword123!")
if(securityEnabled) {
defaultHeaders[i++] = BasicHeader("Authorization", "Basic YWRtaW46YWRtaW4=")
defaultHeaders[i++] = BasicHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString(creds.toByteArray(StandardCharsets.UTF_8)))
}

builder.setDefaultHeaders(defaultHeaders)
Expand Down
Loading