-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing passive_intertransport_auth to facilitate communication b…
…etween nodes with adv sec enabled and nodes without adv sec enabled.(#1156) (Cherry picked from commit 9adcd20)
- Loading branch information
Showing
28 changed files
with
2,790 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...java/com/amazon/opendistroforelasticsearch/security/setting/OpenDistroDynamicSetting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.security.setting; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.elasticsearch.common.settings.ClusterSettings; | ||
import org.elasticsearch.common.settings.Setting; | ||
|
||
/** | ||
* An abstract class to track the state of an opensearch dynamic setting. | ||
* To instantiate for a dynamic setting, pass the Setting and the Setting's fetched value to the constructor | ||
* | ||
* @param <T> The type of the Setting | ||
*/ | ||
public abstract class OpenDistroDynamicSetting<T> { | ||
private final Setting<T> dynamicSetting; | ||
private volatile T dynamicSettingValue; | ||
|
||
private final Logger logger = LogManager.getLogger(getClass()); | ||
|
||
public OpenDistroDynamicSetting(Setting<T> dynamicSetting, T dynamicSettingValue) { | ||
this.dynamicSetting = dynamicSetting; | ||
this.dynamicSettingValue = dynamicSettingValue; | ||
} | ||
|
||
public void registerClusterSettingsChangeListener(final ClusterSettings clusterSettings) { | ||
clusterSettings.addSettingsUpdateConsumer(dynamicSetting, | ||
dynamicSettingNewValue -> { | ||
logger.info(getClusterChangeMessage(dynamicSettingNewValue)); | ||
setDynamicSettingValue(dynamicSettingNewValue); | ||
}); | ||
} | ||
|
||
protected String getClusterChangeMessage(final T dynamicSettingNewValue) { | ||
return String.format("Detected change in settings, updated cluster setting value is %s", dynamicSettingNewValue); | ||
} | ||
|
||
private void setDynamicSettingValue(final T dynamicSettingValue) { | ||
this.dynamicSettingValue = dynamicSettingValue; | ||
} | ||
|
||
public T getDynamicSettingValue() { | ||
return dynamicSettingValue; | ||
} | ||
|
||
public Setting<T> getDynamicSetting() { | ||
return dynamicSetting; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...a/com/amazon/opendistroforelasticsearch/security/setting/TransportPassiveAuthSetting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistroforelasticsearch.security.setting; | ||
|
||
import com.amazon.opendistroforelasticsearch.security.support.ConfigConstants; | ||
import org.elasticsearch.common.settings.Setting; | ||
import org.elasticsearch.common.settings.Settings; | ||
|
||
public class TransportPassiveAuthSetting extends OpenDistroDynamicSetting<Boolean> { | ||
|
||
private static final String SETTING = ConfigConstants.OPENDISTRO_SECURITY_UNSUPPORTED_PASSIVE_INTERTRANSPORT_AUTH_INITIALLY; | ||
|
||
public TransportPassiveAuthSetting(final Settings settings) { | ||
super(getSetting(), getSettingInitialValue(settings)); | ||
} | ||
|
||
private static Setting<Boolean> getSetting() { | ||
return Setting.boolSetting( | ||
SETTING, | ||
false, | ||
Setting.Property.NodeScope, Setting.Property.Dynamic); | ||
} | ||
|
||
private static Boolean getSettingInitialValue(final Settings settings) { | ||
return settings.getAsBoolean(SETTING, false); | ||
} | ||
|
||
@Override | ||
protected String getClusterChangeMessage(final Boolean dynamicSettingNewValue) { | ||
return String.format("Detected change in settings, cluster setting for transportPassiveAuth is %s", dynamicSettingNewValue ? "enabled" : "disabled"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.