Skip to content

Ability to read root credentials from file when bootstrapping #940

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

Merged
merged 3 commits into from
Feb 11, 2025

Conversation

adutra
Copy link
Contributor

@adutra adutra commented Feb 4, 2025

This was initially done in support of #878, which has been closed.

But I think that the feature is still useful, so I went ahead and opened a PR.

PolarisCredentialsBootstrap has been refactored into two components in order to facilitate JSON and YAML parsing: RootCredentialsSet and RootCredentials.

The expected YAML format is as follows:

realm1:
  client-id: client1
  client-secret: secret1
realm2:
  client-id: client2
  client-secret: secret2

@flyrain
Copy link
Contributor

flyrain commented Feb 4, 2025

cc @eric-maynard

Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall 👍 I think it improves usability of the bootstrap command and environment-based runs with auto-bootstrapping (in-memory).

Just a few minor comments and suggestions.

warnOnInMemory();

RootCredentialsSet rootCredentialsSet;
List<String> realms; // TODO Iterable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, waiting for #889

paramLabel = "<realm>",
required = true,
description = "The name of a realm to bootstrap.")
List<String> realms;
Copy link
Contributor

@dimas-b dimas-b Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this as a separate option? Why not extract after parsing the -c value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that users may want to bootstrap a realm without providing credentials (they would be randomly-generated). Should I remove this option? It is true that the file-based approach does not permit randomly-generated credentials.

Copy link
Contributor

@dimas-b dimas-b Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, I missed that use case 🤦

I was just trying to simplify the user experience for the manual case. WDYT about this:

--generate-secrets realm1 --generate-secrets realm2 --credentials realm2,id2,sec2 --credentials realm3,id3,sec3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, honestly... the more it goes, the more I'm in favor of requiring the user to provide all the credentials.

But your suggestion is at least coherent... I'm not opposed to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end, I think it's a minor point compared to the addition of reading secrets from files. We can always refactor that later.

@eric-maynard
Copy link
Contributor

Conceptually I think this PR is great, but we need to standardize on what a "serialized" principal looks like across the APIs, the CLI, and this file format

@dimas-b
Copy link
Contributor

dimas-b commented Feb 5, 2025

[...] we need to standardize on what a "serialized" principal looks like across the APIs, the CLI, and this file format

I do not think establishing a standard for principal serialization should be a blocker for this PR. This change, IMHO, improves user experience already. If the future standard is different, we will fix the tool at the time the standard becomes effective.

Polaris is a young project without a release yet. Users should expect changes in file formats and CLI arguments as the project matures.

paramLabel = "<realm>",
required = true,
description = "The name of a realm to bootstrap.")
List<String> realms;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end, I think it's a minor point compared to the addition of reading secrets from files. We can always refactor that later.

@adutra adutra merged commit 4c1433d into apache:main Feb 11, 2025
5 checks passed
@adutra adutra deleted the read-yaml-creds branch February 11, 2025 12:49
@eric-maynard
Copy link
Contributor

@dimas-b

I do not think establishing a standard for principal serialization should be a blocker for this PR. This change, IMHO, improves user experience already. If the future standard is different, we will fix the tool at the time the standard becomes effective.

It's not necessarily about establishing a standard across the application, but at least within the CLI. #461 was already open proposing a JSON format for the CLI, so it seems odd that we should have merged a change to the CLI that accepts YAML without a consensus about the format to use.

@dimas-b
Copy link
Contributor

dimas-b commented Feb 21, 2025

[...] it seems odd that we should have merged a change to the CLI that accepts YAML without a consensus about the format to use.

I believe this PR did not have any impact on existing functionalities or use cases. So, I do not think this change is an "API" kind of change. Also, as far as I can tell the code in this PR is able to parse the JSON structures proposed in #461.

But point taken on reaching consensus. We can change the format of CLI inputs in #461 or another PR if you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants