-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Auto-configure the elastic user password #78306
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
Auto-configure the elastic user password #78306
Conversation
|
@elasticmachine run elasticsearch-ci/part-2 |
| if (e instanceof ElasticsearchAuthenticationProcessingError) { | ||
| return (ElasticsearchAuthenticationProcessingError) e; | ||
| } | ||
| return createAuthenticationError("error attempting to authenticate request", e, (Object[]) null); |
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.
Only raising exceptions with a specific type (ElasticsearchAuthenticationProcessingError) AND while invoking the request processing error handler (and not any other handler), results in 500 or 503; anything else goes to 401 .
| protected SecureString getBootstrapPassword() { | ||
| return TEST_PASSWORD_SECURE_STRING; | ||
| } | ||
|
|
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.
I need this in order to override to not set the bootstrap password.
|
|
||
| public ReservedRealm(Environment env, Settings settings, NativeUsersStore nativeUsersStore, AnonymousUser anonymousUser, | ||
| SecurityIndexManager securityIndex, ThreadPool threadPool) { | ||
| ThreadPool threadPool) { |
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.
Accounting for if the security index exists is redundant because the native users store does it already.
|
Pinging @elastic/es-security (Team:Security) |
jkakavas
left a comment
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.
This is superb Albert. I like how clean ReservedRealm#doAuthenticate is and the diligence you put into testing. I verified manually too that this does work as advertised ( happy path ) and the test coverage for error cases makes me confident to merge. I'll wait for Lyudmila to share any thoughts are she has spent time on this too and has context from the previous PR, but LGTM from my side
...in/java/org/elasticsearch/xpack/core/security/authc/DefaultAuthenticationFailureHandler.java
Outdated
Show resolved
Hide resolved
...in/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java
Outdated
Show resolved
Hide resolved
...in/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java
Outdated
Show resolved
Hide resolved
jkakavas
left a comment
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.
some testing nits
...rg/elasticsearch/xpack/security/authc/esnative/ReservedRealmElasticAutoconfigIntegTests.java
Outdated
Show resolved
Hide resolved
...curity/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java
Outdated
Show resolved
Hide resolved
...curity/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java
Outdated
Show resolved
Hide resolved
...curity/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java
Outdated
Show resolved
Hide resolved
...curity/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java
Outdated
Show resolved
Hide resolved
...curity/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java
Outdated
Show resolved
Hide resolved
...curity/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java
Show resolved
Hide resolved
|
@elasticmachine test this please |
This commit ensures that for packaged installations we will run the auto-configuration code on installation (but not upgrade) time. This is needed because we expect elasticsearch to be run as a service. By the time the service runs, the configuration directory is not writable by the user that runs elasticsearch so we can't persist configuration and key/certificate material on runtime. Running auto-configuration on installation time allows us to print information to the user that they have better chance of seeing (barring unattended installations). We don't have the option to show output to the user when starting the service with systemctl. During installation we: - Generate TLS material, enable security and TLS and persist on disk - Generate a password for the elastic user and store a hash of this in the elasticsearch.keystore. This will be picked up by the node starting and will be "promoted" to be the cluster wide elastic password on first startup. (see #78306 ) - We notify the user in the output of the package installation about whether we succeed and what the password of the elastic user is.
This adds a new way to specify the initial password for the
elasticsuperuser.This makes use of the new
autoconfiguration.password_hashsecure setting.This setting contains the elastic user's password hash, which is used to validate
the
elastic's credentials, as long as there are no other alternatives in the.securityindex (either if the index does not exist, or if it does not containthe document for the
elasticuser).Still, the interesting thing, which sets this new setting apart from the
bootstrap.passwordexisting one, is that upon a successful validation the hash is written back on the
.securityindex.Importantly, if the write fails, it results in a 500 or 503 error to the client, rather than a 401.
This has the result that all the other nodes will use the same
elasticpassword from the indexfrom that point on.
This whole mechanism facilitates fixing the
elasticuser password, for a cluster, before itsnodes are started.
Replaces #77036
Co-Authored-By: Lyudmila Fokina [email protected]