Skip to content

Commit

Permalink
Replacing default admin password with an opensearch initial admin pas…
Browse files Browse the repository at this point in the history
…sword

Signed-off-by: Joshua Palis <jpalis@amazon.com>
  • Loading branch information
joshpalis committed Jan 17, 2024
1 parent c6e6ed2 commit f79bd04
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def _numNodes = findProperty('numNodes') as Integer ?: 1

ext{

System.setProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD", "myStrongPassword123!")
configureSecurityPlugin = { OpenSearchCluster cluster ->

// Retrieve Security Plugin Zip from zipArchive
Expand All @@ -200,12 +201,14 @@ ext{
}
}

var adminPassword = System.getProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD")

cluster.getNodes().forEach { node ->
var creds = node.getCredentials()
if (creds.isEmpty()) {
creds.add(Map.of('username', 'admin', 'password', 'admin'))
creds.add(Map.of('username', 'admin', 'password', adminPassword))
} else {
creds.get(0).putAll(Map.of('username', 'admin', 'password', 'admin'))
creds.get(0).putAll(Map.of('username', 'admin', 'password', adminPassword))
}
}

Expand Down Expand Up @@ -287,7 +290,7 @@ integTest {
if (System.getProperty('security.enabled') != null) {
is_https = is_https == null ? 'true' : is_https
user = user == null ? 'admin' : user
password = password == null ? 'admin' : password
password = password == null ? System.getProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD") : password
}
systemProperty('https', is_https)
systemProperty('user', user)
Expand Down Expand Up @@ -391,7 +394,7 @@ task integTestRemote(type: RestIntegTestTask) {
if (System.getProperty('security.enabled') != null) {
is_https = is_https == null ? 'true' : is_https
user = user == null ? 'admin' : user
password = password == null ? 'admin' : password
password = password == null ? System.getProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD") : password
}
systemProperty('https', is_https)
systemProperty('user', user)
Expand Down

0 comments on commit f79bd04

Please sign in to comment.