forked from opensearch-project/security
-
Notifications
You must be signed in to change notification settings - Fork 0
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… (
opensearch-project#1156) * Introducing passive_intertransport_auth to facilitate communication between nodes with adv sec enabled and nodes without adv sec enabled. Changes to ssl_dual_mode_enabled to support the same. Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Addressed comments Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Minor fix Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Modifying transportInterClusterPassiveAuth to be controlled by cluster setting instead of opendistro config Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Fixing unit tests Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Resolving conflicts with mainline Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Removing Filtered property from new setting, improving code readability Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Fixing UTs where node space causing shards to be unassigned Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Reverting cluster setting in UT Signed-off-by: Dhiresh Jain <dhireshj@amazon.com> * Addressing minor comment on UT Signed-off-by: Dhiresh Jain <dhireshj@amazon.com>
- Loading branch information
Showing
28 changed files
with
2,795 additions
and
40 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
src/main/java/org/opensearch/security/setting/OpensearchDynamicSetting.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 org.opensearch.security.setting; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.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 OpensearchDynamicSetting<T> { | ||
private final Setting<T> dynamicSetting; | ||
private volatile T dynamicSettingValue; | ||
|
||
private final Logger logger = LogManager.getLogger(getClass()); | ||
|
||
public OpensearchDynamicSetting(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
src/main/java/org/opensearch/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 org.opensearch.security.setting; | ||
|
||
import org.opensearch.security.support.ConfigConstants; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
|
||
public class TransportPassiveAuthSetting extends OpensearchDynamicSetting<Boolean> { | ||
|
||
private static final String SETTING = ConfigConstants.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
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.