Skip to content

Commit 7603dc2

Browse files
authored
Remove whitelist settings in favor of allowlist (opensearch-project#5224)
Signed-off-by: shikharj05 <8859327+shikharj05@users.noreply.github.com>
1 parent 6688955 commit 7603dc2

28 files changed

+22
-1075
lines changed

config/opensearch.yml.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ plugins.security.nodes_dn:
1717
- "CN=node.other.com, OU=SSL, O=Test, L=Test, C=DE"
1818

1919
# The nodes_dn_dynamic_config_enabled settings is geared towards cross_cluster usecases where there is a need to
20-
# manage the whitelisted nodes_dn without having to restart the nodes everytime a new cross_cluster remote is configured
20+
# manage the allowlisted nodes_dn without having to restart the nodes everytime a new cross_cluster remote is configured
2121
# Setting nodes_dn_dynamic_config_enabled to true enables **super-admin callable** /_opendistro/_security/api/nodesdn APIs
2222
# which provide means to update/retrieve nodesdn dynamically.
2323
#
24-
# NOTE: The overall whitelisted nodes_dn evaluated comes from both the plugins.security.nodes_dn and the ones stored
24+
# NOTE: The overall allowlisted nodes_dn evaluated comes from both the plugins.security.nodes_dn and the ones stored
2525
# in security index.
2626
# (default: false)
2727
# NOTE2: This setting only has effect if 'plugins.security.cert.intercluster_request_evaluator_class' is not set.

config/whitelist.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/integrationTest/java/org/opensearch/security/ConfigurationFiles.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public static Path createConfigurationDirectory() {
3333
CType.ROLES.configFileName(),
3434
CType.ROLESMAPPING.configFileName(),
3535
"security_tenants.yml",
36-
CType.TENANTS.configFileName(),
37-
CType.WHITELIST.configFileName() };
36+
CType.TENANTS.configFileName() };
3837
for (String fileName : configurationFiles) {
3938
copyResourceToFile(fileName, tempDirectory.resolve(fileName));
4039
}

src/integrationTest/resources/whitelist.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/main/java/org/opensearch/security/configuration/ConfigurationLoaderSecurity7.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public void noData(String id) {
147147
// Since NODESDN is newly introduced data-type applying for existing clusters as well, we make it backward compatible by
148148
// returning valid empty
149149
// SecurityDynamicConfiguration.
150-
// Same idea for new setting WHITELIST/ALLOWLIST
151-
if (cType == CType.NODESDN || cType == CType.WHITELIST || cType == CType.ALLOWLIST) {
150+
// Same idea for new setting ALLOWLIST
151+
if (cType == CType.NODESDN || cType == CType.ALLOWLIST) {
152152
try {
153153
SecurityDynamicConfiguration<?> empty = ConfigHelper.createEmptySdc(
154154
cType,

src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,6 @@ private void initalizeClusterConfiguration(final boolean installDefaultConfig) {
249249
DEFAULT_CONFIG_VERSION,
250250
populateEmptyIfFileMissing
251251
);
252-
ConfigHelper.uploadFile(
253-
client,
254-
cd + "whitelist.yml",
255-
securityIndex,
256-
CType.WHITELIST,
257-
DEFAULT_CONFIG_VERSION,
258-
populateEmptyIfFileMissing
259-
);
260252
ConfigHelper.uploadFile(
261253
client,
262254
cd + "allowlist.yml",

src/main/java/org/opensearch/security/dlic/rest/api/Endpoint.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public enum Endpoint {
2727
RATELIMITERS,
2828
MIGRATE,
2929
VALIDATE,
30-
WHITELIST,
3130
ALLOWLIST,
3231
NODESDN,
3332
SSL;

src/main/java/org/opensearch/security/dlic/rest/api/SecurityRestApiActions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ public static Collection<RestHandler> getHandler(
9090
new TenantsApiAction(clusterService, threadPool, securityApiDependencies),
9191
new AccountApiAction(clusterService, threadPool, securityApiDependencies, passwordHasher),
9292
new NodesDnApiAction(clusterService, threadPool, securityApiDependencies),
93-
new WhitelistApiAction(clusterService, threadPool, securityApiDependencies),
94-
// FIXME change it as soon as WhitelistApiAction will be removed
9593
new AllowlistApiAction(Endpoint.ALLOWLIST, clusterService, threadPool, securityApiDependencies),
9694
new AuditApiAction(clusterService, threadPool, securityApiDependencies),
9795
new MultiTenancyConfigApiAction(clusterService, threadPool, securityApiDependencies),

src/main/java/org/opensearch/security/dlic/rest/api/WhitelistApiAction.java

Lines changed: 0 additions & 111 deletions
This file was deleted.

src/main/java/org/opensearch/security/filter/SecurityRestFilter.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import org.opensearch.security.privileges.PrivilegesEvaluatorResponse;
5656
import org.opensearch.security.privileges.RestLayerPrivilegesEvaluator;
5757
import org.opensearch.security.securityconf.impl.AllowlistingSettings;
58-
import org.opensearch.security.securityconf.impl.WhitelistingSettings;
5958
import org.opensearch.security.ssl.http.netty.Netty4HttpRequestHeaderVerifier;
6059
import org.opensearch.security.ssl.transport.PrincipalExtractor;
6160
import org.opensearch.security.ssl.util.ExceptionUtils;
@@ -86,7 +85,6 @@ public class SecurityRestFilter {
8685
private final Path configPath;
8786
private final CompatConfig compatConfig;
8887

89-
private WhitelistingSettings whitelistingSettings;
9088
private AllowlistingSettings allowlistingSettings;
9189

9290
public static final String HEALTH_SUFFIX = "health";
@@ -114,7 +112,6 @@ public SecurityRestFilter(
114112
this.settings = settings;
115113
this.configPath = configPath;
116114
this.compatConfig = compatConfig;
117-
this.whitelistingSettings = new WhitelistingSettings();
118115
this.allowlistingSettings = new AllowlistingSettings();
119116
}
120117

@@ -179,8 +176,7 @@ public void handleRequest(RestRequest request, RestChannel channel, NodeClient c
179176
if (user != null) {
180177
auditLog.logSucceededLogin(user.getName(), false, intiatingUser, requestChannel);
181178
}
182-
final Optional<SecurityResponse> deniedResponse = whitelistingSettings.checkRequestIsAllowed(requestChannel)
183-
.or(() -> allowlistingSettings.checkRequestIsAllowed(requestChannel));
179+
final Optional<SecurityResponse> deniedResponse = allowlistingSettings.checkRequestIsAllowed(requestChannel);
184180

185181
if (deniedResponse.isPresent()) {
186182
channel.sendResponse(deniedResponse.get().asRestResponse());
@@ -207,7 +203,7 @@ public void handleRequest(RestRequest request, RestChannel channel, NodeClient c
207203
* If allowlisting is enabled, then Non-SuperAdmin is allowed to access only those APIs that are allowlisted in {@link #requests}
208204
* For example: if allowlisting is enabled and requests = ["/_cat/nodes"], then SuperAdmin can access all APIs, but non SuperAdmin
209205
* can only access "/_cat/nodes"
210-
* Further note: Some APIs are only accessible by SuperAdmin, regardless of allowlisting. For example: /_opendistro/_security/api/whitelist is only accessible by SuperAdmin.
206+
* Further note: Some APIs are only accessible by SuperAdmin, regardless of allowlisting. For example: /_opendistro/_security/api/allowlist is only accessible by SuperAdmin.
211207
* See {@link AllowlistApiAction} for the implementation of this API.
212208
* SuperAdmin is identified by credentials, which can be passed in the curl request.
213209
*/
@@ -320,11 +316,6 @@ public void checkAndAuthenticateRequest(SecurityRequestChannel requestChannel) t
320316
}
321317
}
322318

323-
@Subscribe
324-
public void onWhitelistingSettingChanged(WhitelistingSettings whitelistingSettings) {
325-
this.whitelistingSettings = whitelistingSettings;
326-
}
327-
328319
@Subscribe
329320
public void onAllowlistingSettingChanged(AllowlistingSettings allowlistingSettings) {
330321
this.allowlistingSettings = allowlistingSettings;

0 commit comments

Comments
 (0)