Fix error message when changing the password for a user in the file realm #127621
+101
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 leverages
fileUserPasswdStore.userExists
to do a low cost check on whether the request username belongs to thefile
realm and will exit early with an informative error message if that is the case.