Skip to content

Commit

Permalink
reset sec plugin.java
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <[email protected]>
  • Loading branch information
stephen-crawford committed Sep 13, 2023
1 parent 4079fe8 commit d0b26ed
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 54 deletions.
4 changes: 0 additions & 4 deletions config/opensearch.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ plugins.security.authcz.admin_dn:
# BOTH - backend roles are mapped to Security roles mapped directly and via roles_mapping.yml in addition
plugins.security.roles_mapping_resolution: MAPPING_ONLY

# Specify the default password for the admin user
# Note: This setting is required for using the default admin user account
plugins.security.bootstrap.admin.password: test

############## REST Management API configuration settings ##############
# Enable or disable role based access to the REST management API
# Default is that no role is allowed to access the REST management API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,6 @@ public OpenSearchSecurityPlugin(final Settings settings, final Path configPath)

transportPassiveAuthSetting = new TransportPassiveAuthSetting(settings);

if (settings.get(ConfigConstants.SECURITY_BOOTSTRAP_ADMIN_DEFAULT_PASSWORD) == null) {
throw new RuntimeException("A default admin password must be provided in the opensearch.yml file.");
}
System.setProperty(ConfigConstants.SECURITY_BOOTSTRAP_ADMIN_DEFAULT_PASSWORD, settings.get(ConfigConstants.SECURITY_BOOTSTRAP_ADMIN_DEFAULT_PASSWORD));
runAdminTool();

if (disabled) {
this.sslCertReloadEnabled = false;
log.warn(
Expand Down Expand Up @@ -1211,10 +1205,6 @@ public List<Setting<?>> getSettings() {
)
); // not filtered here

settings.add(
Setting.simpleString(ConfigConstants.SECURITY_BOOTSTRAP_ADMIN_DEFAULT_PASSWORD, Property.NodeScope, Property.Filtered)
);

settings.add(Setting.simpleString(ConfigConstants.SECURITY_CONFIG_INDEX_NAME, Property.NodeScope, Property.Filtered));
settings.add(Setting.groupSetting(ConfigConstants.SECURITY_AUTHCZ_IMPERSONATION_DN + ".", Property.NodeScope)); // not filtered
// here
Expand Down Expand Up @@ -1929,46 +1919,6 @@ private static String handleKeyword(final String field) {
return field;
}

public static void runAdminTool() {

System.out.println("Checking OS");
boolean isWindows = (System.getProperty("os.name").toLowerCase().contains("win"));
// Specify the path to your shell script
String scriptPath = "../../../tools/admin_password_tool" + (isWindows ? ".bat" : ".sh");

System.out.println("Script path is " + scriptPath);

try {
// Create a ProcessBuilder for the shell script
ProcessBuilder processBuilder = new ProcessBuilder();

if (isWindows) {
processBuilder.command("cmd.exe", "/c", scriptPath);
} else {
processBuilder.command("sh", scriptPath);
}

System.out.println("Processor has command array of: " + Arrays.stream(processBuilder.command().toArray()).map(Object::toString).collect(Collectors.joining(" ")));

// Start the process
Process process = processBuilder.start();
System.out.println("Process started");


// Wait for the process to complete
int exitCode = process.waitFor();

if (exitCode == 0) {
System.out.println("Shell script executed successfully.");
} else {
System.err.println("Shell script execution failed with exit code " + exitCode);
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}


public static class GuiceHolder implements LifecycleComponent {

private static RepositoriesService repositoriesService;
Expand Down

0 comments on commit d0b26ed

Please sign in to comment.