-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Add a tool for creating enrollment tokens #74890
Conversation
This change introduces a CLI tool that can be used to create enrollment tokens. It doesn't require credentials, but simply write access to the local filesystem of a node. It uses an auto-generated user in the file-realm with superuser role. For this purpose, this change also introduces a base class for a CLI tool that can be used by any CLI tool needs to perform actions against an ES node as a superuser without requiring credentials from the user. It is worth noting that this doesn't change our existing thread model, because already an actor with write access to the fs of an ES node, can become superuser (again, by adding a superuser to the file realm, albeit manually).
Pinging @elastic/es-security (Team:Security) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive by ...
.../security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java
Outdated
Show resolved
Hide resolved
.../security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java
Outdated
Show resolved
Hide resolved
…l execute the command if they so wish to do
.../security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java
Outdated
Show resolved
Hide resolved
Thanks for requesting a review, but my original comments were just a drive-by, I don't think I need to do a full review unless you specifically want it. Feel free to merge when you have the OK from the project team. |
I just triggered the button on the top right mostly so that you get the PR in the GH list of PRs for convenience. Thanks for the drive-by comments ! |
...rc/main/java/org/elasticsearch/xpack/security/enrollment/tool/CreateEnrollmentTokenTool.java
Show resolved
Hide resolved
...rc/main/java/org/elasticsearch/xpack/security/enrollment/tool/CreateEnrollmentTokenTool.java
Show resolved
Hide resolved
.../security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java
Outdated
Show resolved
Hide resolved
.../security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java
Outdated
Show resolved
Hide resolved
.../security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java
Outdated
Show resolved
Hide resolved
.../security/src/main/java/org/elasticsearch/xpack/security/tool/BaseRunAsSuperuserCommand.java
Outdated
Show resolved
Hide resolved
...st/java/org/elasticsearch/xpack/security/enrollment/tool/BaseRunAsSuperuserCommandTests.java
Show resolved
Hide resolved
...st/java/org/elasticsearch/xpack/security/enrollment/tool/CreateEnrollmentTokenToolTests.java
Show resolved
Hide resolved
part-1-fips failed because of #75221, unrelated flaky test |
@elasticsearchmachine run elasticsearch-ci/part-1-fips |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@elasticmachine run elasticsearch-ci/docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few non-blocking suggested changes. LGTM otherwise 🥳
5d96a9b
to
b373f85
Compare
settings = env.settings(); | ||
} | ||
|
||
ensureFileRealmEnabled(settings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because file realms don't have Secure Settings, I would move this before the password prompt, and maybe make it the base implementation of validate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We chatted and we're moving ensureFileRealmEnabled(settings);
higher up but not adding it to a default implementation of validate()
attributesChecker.check(terminal); | ||
final boolean forceExecution = options.has(force); | ||
checkClusterHealthWithRetries(newEnv, terminal, 5, forceExecution); | ||
executeCommand(terminal, options, newEnv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would pass the username and password to this method instead of making them class members. It's more clear the lifecycle like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'd need to pass them as parameters to all checkClusterHealthWithRetries, executeCommand, cleanup. I like the fact that we keep ownership of the password here and close it in all cases etc. Happy to change, but I miss the point of "It's more clear the lifecycle like this." , I'll ping you to chat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we chatted and I made the change as suggested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I only had two very minor comments.
This change introduces a CLI tool that can be used to create enrollment tokens. It doesn't require credentials, but simply write access to the local filesystem of a node. It uses an auto-generated user in the file-realm with superuser role. For this purpose, this change also introduces a base class for a CLI tool that can be used by any CLI tool needs to perform actions against an ES node as a superuser without requiring credentials from the user. It is worth noting that this doesn't change our existing thread model, because already an actor with write access to the fs of an ES node, can become superuser (again, by adding a superuser to the file realm, albeit manually). Co-authored-by: Adam Locke <[email protected]>
This change introduces a CLI tool that can be used to create enrollment tokens. It doesn't require credentials, but simply write access to the local filesystem of a node. It uses an auto-generated user in the file-realm with superuser role. For this purpose, this change also introduces a base class for a CLI tool that can be used by any CLI tool needs to perform actions against an ES node as a superuser without requiring credentials from the user. It is worth noting that this doesn't change our existing thread model, because already an actor with write access to the fs of an ES node, can become superuser (again, by adding a superuser to the file realm, albeit manually). Co-authored-by: Adam Locke <[email protected]>
This change introduces a CLI tool that can be used to create
enrollment tokens. It doesn't require credentials, but simply
write access to the local filesystem of a node. It uses an
auto-generated user in the file-realm with superuser role.
For this purpose, this change also introduces a base class for a
CLI tool that can be used by any CLI tool needs to perform actions
against an ES node as a superuser without requiring credentials
from the user. It is worth noting that this doesn't change our
existing thread model, because already an actor with write access
to the filesystem of an ES node, can become superuser (again, by
adding a superuser to the file realm, albeit manually).