mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 18:35:25 +00:00
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,
|
securityInterceptor.set(new SecurityServerTransportInterceptor(settings, threadPool, authcService.get(), authzService, licenseState,
|
||||||
sslService, securityContext.get(), destructiveOperations));
|
sslService, securityContext.get(), destructiveOperations));
|
||||||
|
|
||||||
BootstrapElasticPassword bootstrapElasticPassword = new BootstrapElasticPassword(settings, logger, clusterService, reservedRealm,
|
BootstrapElasticPassword bootstrapElasticPassword = new BootstrapElasticPassword(settings, clusterService, reservedRealm,
|
||||||
securityLifecycleService);
|
securityLifecycleService);
|
||||||
bootstrapElasticPassword.initiatePasswordBootstrap();
|
bootstrapElasticPassword.initiatePasswordBootstrap();
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import org.elasticsearch.action.ActionListener;
|
|||||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||||
import org.elasticsearch.cluster.ClusterStateListener;
|
import org.elasticsearch.cluster.ClusterStateListener;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
import org.elasticsearch.cluster.service.ClusterService;
|
||||||
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.settings.SecureString;
|
import org.elasticsearch.common.settings.SecureString;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.gateway.GatewayService;
|
import org.elasticsearch.gateway.GatewayService;
|
||||||
@ -38,11 +39,11 @@ public final class BootstrapElasticPassword {
|
|||||||
private final SecurityLifecycleService lifecycleService;
|
private final SecurityLifecycleService lifecycleService;
|
||||||
private final boolean reservedRealmDisabled;
|
private final boolean reservedRealmDisabled;
|
||||||
|
|
||||||
public BootstrapElasticPassword(Settings settings, Logger logger, ClusterService clusterService, ReservedRealm reservedRealm,
|
public BootstrapElasticPassword(Settings settings, ClusterService clusterService, ReservedRealm reservedRealm,
|
||||||
SecurityLifecycleService lifecycleService) {
|
SecurityLifecycleService lifecycleService) {
|
||||||
this.reservedRealmDisabled = XPackSettings.RESERVED_REALM_ENABLED_SETTING.get(settings) == false;
|
this.reservedRealmDisabled = XPackSettings.RESERVED_REALM_ENABLED_SETTING.get(settings) == false;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.logger = logger;
|
this.logger = Loggers.getLogger(BootstrapElasticPassword.class, settings);
|
||||||
this.clusterService = clusterService;
|
this.clusterService = clusterService;
|
||||||
this.reservedRealm = reservedRealm;
|
this.reservedRealm = reservedRealm;
|
||||||
this.lifecycleService = lifecycleService;
|
this.lifecycleService = lifecycleService;
|
||||||
@ -98,7 +99,9 @@ public final class BootstrapElasticPassword {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(Boolean passwordSet) {
|
public void onResponse(Boolean passwordSet) {
|
||||||
cleanup();
|
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");
|
logger.warn("elastic password was not bootstrapped because its password was already set");
|
||||||
}
|
}
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
|
@ -50,7 +50,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testNoListenerAttachedWhenNoBootstrapPassword() {
|
public void testNoListenerAttachedWhenNoBootstrapPassword() {
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(Settings.EMPTY, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(Settings.EMPTY, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.put(XPackSettings.RESERVED_REALM_ENABLED_SETTING.getKey(), false)
|
.put(XPackSettings.RESERVED_REALM_ENABLED_SETTING.getKey(), false)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
expectThrows(ValidationException.class, bootstrap::initiatePasswordBootstrap);
|
expectThrows(ValidationException.class, bootstrap::initiatePasswordBootstrap);
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ public class BootstrapElasticPasswordTests extends ESTestCase {
|
|||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.setSecureSettings(secureSettings)
|
.setSecureSettings(secureSettings)
|
||||||
.build();
|
.build();
|
||||||
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, logger, clusterService, realm, lifecycle);
|
BootstrapElasticPassword bootstrap = new BootstrapElasticPassword(settings, clusterService, realm, lifecycle);
|
||||||
|
|
||||||
bootstrap.initiatePasswordBootstrap();
|
bootstrap.initiatePasswordBootstrap();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user