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

Remove references to admin:admin #551

Merged
merged 12 commits into from
Jan 26, 2024
9 changes: 4 additions & 5 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,11 @@ Additionally, it is also possible to run a cluster with security enabled:
./gradlew run -Dsecurity.enabled=true
```

By default, if `-Dsecurity.enabled=true` is passed the following defaults will be used: `https=true`, `user=admin` and
`password=admin`.
By default, if `-Dsecurity.enabled=true` is passed the following defaults will be used: `https=true`, `user=admin`. There is no default password and it is to be set as `password=<admin-password>`.

Then, to access the cluster, we can run
Then, to access the cluster, we can run the below command. <admin-password> parameter is the password set by admin.
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
```bash
curl https://localhost:9200 --insecure -u admin:admin
curl https://localhost:9200 --insecure -u admin:<admin-password>

{
"name" : "integTest-0",
Expand Down Expand Up @@ -191,7 +190,7 @@ Integration tests can be run with remote cluster. For that run the following com
In case remote cluster is secured it's possible to pass username and password with the following command:

```
./gradlew :integTestRemote -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="integTest-0" -Dhttps=true -Duser=admin -Dpassword=admin
./gradlew :integTestRemote -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="integTest-0" -Dhttps=true -Duser=admin -Dpassword=<admin-password>
```

### Debugging
Expand Down
16 changes: 13 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import org.opensearch.gradle.test.RestIntegTestTask
import org.opensearch.gradle.testclusters.OpenSearchCluster
import org.opensearch.gradle.Version

import java.nio.file.Paths
import java.util.concurrent.Callable
Expand Down Expand Up @@ -62,6 +63,15 @@ def opensearch_tmp_dir = rootProject.file('build/private/opensearch_tmp').absolu
opensearch_tmp_dir.mkdirs()

ext {
var versionsWithoutDefaultAdminPassword = System.getProperty("versionsWithoutDefaultAdminPassword").toString()
Version currentVersion= Version.fromString(version_tokens[0])
Version versionWithoutDefaultAdminPassword=Version.fromString(versionsWithoutDefaultAdminPassword)
if(currentVersion.onOrAfter(versionWithoutDefaultAdminPassword)){
System.setProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD", "myStrongPassword123!")
}else{
System.setProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD", "admin")
}

isSnapshot = "true" == System.getProperty("build.snapshot", "true")
projectSubstitutions = [:]

Expand All @@ -85,9 +95,9 @@ ext {
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', System.getProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD")))
} else {
creds.get(0).putAll(Map.of('username', 'admin', 'password', 'admin'))
creds.get(0).putAll(Map.of('username', 'admin', 'password', System.getProperty("OPENSEARCH_INITIAL_ADMIN_PASSWORD")))
}
}

Expand Down Expand Up @@ -302,7 +312,7 @@ integTest {
// If security is enabled, set is_https/user/password defaults
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
vibrantvarun marked this conversation as resolved.
Show resolved Hide resolved
}
systemProperty("https", is_https)
systemProperty("user", user)
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAME
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

#versions with not having default password as admin
systemProp.versionsWithoutDefaultAdminPassword=2.12.0
Loading