-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix error message when changing the password for a user in the file realm #127621
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
base: main
Are you sure you want to change the base?
Fix error message when changing the password for a user in the file realm #127621
Conversation
… user attempts to update the password for the `elastic` superuser in a cloud deployment. At the heart of the issue is the difference in how the `elastic` superuser is implemented on self-hosted deployments vs. managed cloud deployments. Elasticsearch has two distinct security realms: `file` and `native`. On a self-hosted deployment, the `elastic` superuser is represented as a document in the `.security` index, whereas in a cloud deployment `elastic` is defined in the `ES_PATH_CONF/users` and `ES_PATH_CONF/user_roles` files placed on each node in the cluster. The TransportChangePasswordAction impl is designed to update the password for users in the `native` realm specifically, and a failure on cloud to change the password for `elastic` using the Change Password API fails with the error that the user does not exist. The solution here leverages `fileUserPasswdStore.userExists` to do a low cost check on whether the request username belongs to the `file` realm and will exit early with an informative error message if that is the case.
Hi @ankit--sethi, I've created a changelog YAML for you. |
Pinging @elastic/es-security (Team:Security) |
…uestions around CI/CD are resolved.
…' into feature/misleading-error-message
Hi @ankit--sethi, I've updated the changelog YAML for you. |
Optional<Realm> realm = realms.stream().filter(t -> FileRealmSettings.TYPE.equalsIgnoreCase(t.type())).findAny(); | ||
if (user == null && realm.isPresent()) { | ||
// we should check if this request is mistakenly trying to reset a file realm user | ||
FileRealm fileRealm = (FileRealm) realm.get(); |
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.
Why only file realms? Couldn't we just do this for all realms?
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.
fair point, maybe we can? I'm gonna take a closer look to see if there are any gotchas to doing that.
…' into feature/misleading-error-message
This PR addresses #113535 - a confusing error message when the user attempts to update the password for the
elastic
superuser in a cloud deployment.At the heart of the issue is the difference in how the
elastic
superuser is implemented on self-hosted deployments vs. managed cloud deployments. Elasticsearch has two distinct security realms:file
andnative
. On a self-hosted deployment, theelastic
superuser is represented as a document in the.security
index (placing it in thenative
realm), whereas in a cloud deploymentelastic
is defined in theES_PATH_CONF/users
andES_PATH_CONF/user_roles
files installed on each node in the cluster (placing it in thefile
realm).The
TransportChangePasswordAction
impl is designed to update the password for users in thenative
realm specifically, and on cloud an attempt to change the password forelastic
using the Change Password API fails with the error that the user does not exist. This is misleading since the user exists but is simply coming from thefile
realm.The solution here first checks if the user is not found in the native realm - if that is the case it checks the file realm in case the user is present there. This case is provided a new error message. Other cases end in a "user not found" state or proceed to invoke
changePassword
.