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

Renames initialAdminPassword to OPENSEARCH_INITIAL_ADMIN_PASSWORD to be compliant with opensearch naming convention #3843

Merged
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
4 changes: 2 additions & 2 deletions .github/actions/start-opensearch-with-one-plugin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ runs:
'y' | .\opensearch-${{ inputs.opensearch-version }}-SNAPSHOT\bin\opensearch-plugin.bat install file:$(pwd)\${{ inputs.plugin-name }}.zip
shell: pwsh

- name: Write password to initialAdminPassword location
- name: Write password to opensearch_initial_admin_password txt
run:
echo ${{ inputs.admin-password }} >> ./opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT/config/initialAdminPassword.txt
echo ${{ inputs.admin-password }} >> ./opensearch-${{ env.OPENSEARCH_VERSION }}-SNAPSHOT/config/opensearch_initial_admin_password.txt
shell: bash

# Run any configuration scripts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ public enum RolesMappingResolution {
public static final boolean EXTENSIONS_BWC_PLUGIN_MODE_DEFAULT = false;
// CS-ENFORCE-SINGLE

// Variables for initial admin password support
public static final String OPENSEARCH_INITIAL_ADMIN_PASSWORD = "OPENSEARCH_INITIAL_ADMIN_PASSWORD";
public static final String OPENSEARCH_INITIAL_ADMIN_PASSWORD_TXT = "opensearch_initial_admin_password.txt";

public static Set<String> getSettingAsSet(
final Settings settings,
final String key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.opensearch.security.DefaultObjectMapper;
import org.opensearch.security.dlic.rest.validation.PasswordValidator;
import org.opensearch.security.dlic.rest.validation.RequestContentValidator;
import org.opensearch.security.support.ConfigConstants;
import org.opensearch.security.tools.Hasher;

import org.yaml.snakeyaml.DumperOptions;
Expand Down Expand Up @@ -94,8 +95,8 @@
* Replaces the admin password in internal_users.yml with the custom or generated password
*/
void updateAdminPassword() {
String initialAdminPassword = System.getenv().get("initialAdminPassword");
String ADMIN_PASSWORD_FILE_PATH = installer.OPENSEARCH_CONF_DIR + "initialAdminPassword.txt";
String initialAdminPassword = System.getenv().get(ConfigConstants.OPENSEARCH_INITIAL_ADMIN_PASSWORD);
String ADMIN_PASSWORD_FILE_PATH = installer.OPENSEARCH_CONF_DIR + ConfigConstants.OPENSEARCH_INITIAL_ADMIN_PASSWORD_TXT;
String INTERNAL_USERS_FILE_PATH = installer.OPENSEARCH_CONF_DIR + "opensearch-security" + File.separator + "internal_users.yml";
boolean shouldValidatePassword = installer.environment.equals(ExecutionEnvironment.DEMO);
try {
Expand All @@ -115,7 +116,9 @@
try (BufferedReader br = new BufferedReader(new FileReader(ADMIN_PASSWORD_FILE_PATH, StandardCharsets.UTF_8))) {
ADMIN_PASSWORD = br.readLine();
} catch (IOException e) {
System.out.println("Error reading admin password from initialAdminPassword.txt.");
System.out.println(

Check warning on line 119 in src/main/java/org/opensearch/security/tools/democonfig/SecuritySettingsConfigurer.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/security/tools/democonfig/SecuritySettingsConfigurer.java#L119

Added line #L119 was not covered by tests
"Error reading admin password from " + ConfigConstants.OPENSEARCH_INITIAL_ADMIN_PASSWORD_TXT + "."
);
System.exit(-1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import org.opensearch.security.support.ConfigConstants;
import org.opensearch.security.tools.democonfig.util.NoExitSecurityManager;

import static org.hamcrest.MatcherAssert.assertThat;
Expand All @@ -55,7 +56,7 @@ public class SecuritySettingsConfigurerTests {
private final PrintStream originalErr = System.err;
private final InputStream originalIn = System.in;

private final String adminPasswordKey = "initialAdminPassword";
private final String adminPasswordKey = ConfigConstants.OPENSEARCH_INITIAL_ADMIN_PASSWORD;

private static SecuritySettingsConfigurer securitySettingsConfigurer;

Expand Down
Loading