Skip to content

Commit

Permalink
Fixes base64 encoded hardcoded admin credentials (opensearch-project#…
Browse files Browse the repository at this point in the history
…1331) (opensearch-project#1333)

* Fixes base64 encoded hardcoded admin credentials

Signed-off-by: Darshit Chanpura <[email protected]>

* Fixes broken integTest task

Signed-off-by: Darshit Chanpura <[email protected]>

---------

Signed-off-by: Darshit Chanpura <[email protected]>
(cherry picked from commit 74dfcd1)

Co-authored-by: Darshit Chanpura <[email protected]>
opensearch-trigger-bot[bot] and DarshitChanpura authored Feb 15, 2024

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent 72c504f commit 91c5fad
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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")
Original file line number Diff line number Diff line change
@@ -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
@@ -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)

0 comments on commit 91c5fad

Please sign in to comment.