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

[Extensions] Parse configuration file of extensions during installation, pass this information to the Security Plugin #2667

Closed
Tracked by #2596
stephen-crawford opened this issue Apr 10, 2023 · 3 comments
Labels
triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.

Comments

@stephen-crawford
Copy link
Contributor

stephen-crawford commented Apr 10, 2023

After merging #2594, we will need to have a way for core to parse the configuration files of extensions during installation and then pass that information to the Security plugin. Once in the Security plugin, a service account can be created based on the information provided in the extension's configuration files.

Completion of the issue will look like a PR which adds functionality for parsing a configuration file in core during bootstrap and then passing that information from core into the Security plugin. The base PR should include tests which demonstrate the successful parsing of a configuration file and creation of a payload which can be sent to the Security plugin.

A follow-up PR will need to be created after this issue is completed which adds the automatic handling of the created payload and the subsequent creation of the service account for the extension.

@stephen-crawford stephen-crawford converted this from a draft issue Apr 10, 2023
@stephen-crawford stephen-crawford self-assigned this Apr 10, 2023
@stephen-crawford stephen-crawford added the triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable. label Apr 10, 2023
@github-actions github-actions bot added the untriaged Require the attention of the repository maintainers and may need to be prioritized label Apr 10, 2023
@stephen-crawford stephen-crawford removed the untriaged Require the attention of the repository maintainers and may need to be prioritized label Apr 10, 2023
@stephen-crawford
Copy link
Contributor Author

[Triage] This issue is part of the ongoing work with the extensions project.

@cwperks
Copy link
Member

cwperks commented May 16, 2023

@scrawfor99 I have an open PR in core for an IdentityPlugin to extend the settings in extensions.yml: opensearch-project/OpenSearch#7526

Does that PR address this issue?

@stephen-crawford stephen-crawford moved this from Todo to Done in Security for Extensions May 16, 2023
@stephen-crawford
Copy link
Contributor Author

Hi @cwperks, I think that between that and the work that was already done in the ExtensionsManager class. This issue should be all set. This code gets most of the info we would realistically need:

 private ExtensionsSettings readFromExtensionsYml(Path filePath) throws IOException {
        Yaml yaml = new Yaml();
        try (InputStream inputStream = Files.newInputStream(filePath)) {
            Map<String, Object> obj = yaml.load(inputStream);
            if (obj == null) {
                inputStream.close();
                throw new IOException("extensions.yml is empty");
            }
            List<HashMap<String, ?>> unreadExtensions = new ArrayList<>((Collection<HashMap<String, ?>>) obj.get("extensions"));
            List<Extension> readExtensions = new ArrayList<Extension>();
            for (HashMap<String, ?> extensionMap : unreadExtensions) {
                try {
                    // checking to see whether any required fields are missing from extension.yml file or not
                    String[] requiredFields = {
                        "name",
                        "uniqueId",
                        "hostAddress",
                        "port",
                        "version",
                        "opensearchVersion",
                        "minimumCompatibleVersion" };
                    List<String> missingFields = Arrays.stream(requiredFields)
                        .filter(field -> !extensionMap.containsKey(field))
                        .collect(Collectors.toList());
                    if (!missingFields.isEmpty()) {
                        throw new IOException("Extension is missing these required fields : " + missingFields);
                    }

@stephen-crawford stephen-crawford removed their assignment May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issues labeled as 'Triaged' have been reviewed and are deemed actionable.
Projects
Status: Done
Development

No branches or pull requests

2 participants