Add log when elastic password boostrapped (elastic/x-pack-elasticsearch#2053)
This is related to elastic/x-pack-elasticsearch#1217. This adds a log message to inform the user when the elastic user's password is bootsrapped successfully. Original commit: elastic/x-pack-elasticsearch@8d30e163ec
This commit is contained in:
parent
5056d4e3df
commit
495fc21c37
|
@ -394,7 +394,7 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin {
|
|||
securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(), authzService, licenseState,
|
||||
sslService, securityContext.get(), destructiveOperations));
|
||||
|
||||
BootstrapElasticPassword bootstrapElasticPassword = new BootstrapElasticPassword(settings, logger, clusterService, reservedRealm,
|
||||
BootstrapElasticPassword bootstrapElasticPassword = new BootstrapElasticPassword(settings, clusterService, reservedRealm,
|
||||
securityLifecycleService);
|
||||
bootstrapElasticPassword.initiatePasswordBootstrap();
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.action.ActionListener;
|
|||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||
import org.elasticsearch.cluster.ClusterStateListener;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.SecureString;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.gateway.GatewayService;
|
||||
|
@ -38,11 +39,11 @@ public final class BootstrapElasticPassword {
|
|||
private final SecurityLifecycleService lifecycleService;
|
||||
private final boolean reservedRealmDisabled;
|
||||
|
||||
public BootstrapElasticPassword(Settings settings, Logger logger, ClusterService clusterService, ReservedRealm reservedRealm,
|
||||
public BootstrapElasticPassword(Settings settings, ClusterService clusterService, ReservedRealm reservedRealm,
|
||||
SecurityLifecycleService lifecycleService) {
|
||||
this.reservedRealmDisabled = XPackSettings.RESERVED_REALM_ENABLED_SETTING.get(settings) == false;
|
||||
this.settings = settings;
|
||||
this.logger = logger;
|
||||
this.logger = Loggers.getLogger(BootstrapElasticPassword.class, settings);
|
||||
this.clusterService = clusterService;
|
||||
this.reservedRealm = reservedRealm;
|
||||
this.lifecycleService = lifecycleService;
|
||||
|
@ -98,7 +99,9 @@ public final class BootstrapElasticPassword {
|
|||
@Override
|
||||
public void onResponse(Boolean passwordSet) {
|
||||
cleanup();
|
||||
if (passwordSet == false) {
|
||||
if (passwordSet) {
|
||||
logger.info("elastic password was bootstrapped successfully");
|
||||
} else {
|
||||
logger.warn("elastic password was not bootstrapped because its password was already set");
|
||||
}
|
||||
semaphore.release();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testNoListenerAttachedWhenNoBootstrapPassword() {
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(Settings.EMPTY, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(Settings.EMPTY, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
.setSecureSettings(secureSettings)
|
||||
.put(XPackSettings.RESERVED_REALM_ENABLED_SETTING.getKey(), false)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
expectThrows(ValidationException.class, bootstrap::initiatePasswordBootstrap);
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -118,7 +118,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -168,7 +168,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -193,7 +193,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -228,7 +228,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -255,7 +255,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
@ -308,7 +308,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||
Settings settings = Settings.builder()
|
||||
.setSecureSettings(secureSettings)
|
||||
.build();
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||
|
||||
bootstrap.initiatePasswordBootstrap();
|
||||
|
||||
|
|
Loading…
Reference in New Issue