Skip to content

Commit fc88809

Browse files
committed
Fixed issue with "Update is not supported when FLS or DLS or Fieldmasking is active" in Dashboards multi tenancy
Signed-off-by: Nils Bandener <[email protected]>
1 parent 634e80f commit fc88809

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2020
- Use RestRequestFilter.getFilteredRequest to declare sensitive API params ([#5710](https://github.com/opensearch-project/security/pull/5710))
2121
- Fix deprecated SSL transport settings in demo certificates ([#5723](https://github.com/opensearch-project/security/pull/5723))
2222
- Updates DlsFlsValveImpl condition to return true if request is internal and not a protected resource request ([#5721](https://github.com/opensearch-project/security/pull/5721))
23+
- Update operations on `.kibana` system index now work correctly with Dashboards multi tenancy enabled. ([#5778](https://github.com/opensearch-project/security/pull/5778))
2324

2425
### Refactoring
2526
- [Resource Sharing] Make migrate api require default access level to be supplied and updates documentations + tests ([#5717](https://github.com/opensearch-project/security/pull/5717))

src/integrationTest/java/org/opensearch/security/privileges/int_tests/DashboardMultiTenancyIntTests.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import static org.opensearch.test.framework.matcher.RestMatchers.isForbidden;
4242
import static org.opensearch.test.framework.matcher.RestMatchers.isOk;
4343
import static org.junit.Assert.assertEquals;
44-
import static org.junit.Assert.assertTrue;
4544

4645
/**
4746
* An integration test matrix for Dashboards multi-tenancy. Verifies both read and write operations
@@ -660,25 +659,13 @@ public void bulkWithUpdate_withTenantHeader_humanResources() {
660659
);
661660

662661
if (user.reference(WRITE).covers(dashboards_index_human_resources)) {
663-
if (user == GLOBAL_TENANT_READ_WRITE_USER || user == WILDCARD_TENANT_USER) {
664-
assertThat(response, isOk());
665-
assertThat(
666-
response,
667-
containsExactly(dashboards_index_human_resources).at("items[*].update[?(@.result == 'updated')]._index")
668-
.reducedBy(user.reference(WRITE))
669-
.whenEmpty(isOk())
670-
);
671-
} else {
672-
// At the moment, we get here a nested error:
673-
// Update is not supported when FLS or DLS or Fieldmasking is activated
674-
// This is a bug; even though it does not seem to have an impact on Dashboards functionality
675-
assertThat(response, isOk());
676-
assertTrue(
677-
response.getBody(),
678-
response.getBody().contains("Update is not supported when FLS or DLS or Fieldmasking is activated")
679-
);
680-
}
681-
662+
assertThat(response, isOk());
663+
assertThat(
664+
response,
665+
containsExactly(dashboards_index_human_resources).at("items[*].update[?(@.result == 'updated')]._index")
666+
.reducedBy(user.reference(WRITE))
667+
.whenEmpty(isOk())
668+
);
682669
} else {
683670
assertThat(
684671
response,

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ public boolean invoke(PrivilegesEvaluationContext context, final ActionListener<
191191
DlsFlsProcessedConfig config = this.dlsFlsProcessedConfig.get();
192192
IndexResolverReplacer.Resolved resolved = context.getResolvedRequest();
193193

194+
DocumentAllowList documentAllowList = DocumentAllowList.get(threadContext);
195+
196+
if (!resolved.isLocalAll() && resolved.getAllIndices().stream().anyMatch(index -> documentAllowList.isAllowed(index, "*"))) {
197+
// The documentAllowList is needed here for Dashboards multi tenancy which can redirect index accesses to indices for which no
198+
// normal index privileges are present
199+
// If we would not use the documentAllowList here, the index would appear to be protected
200+
201+
if (resolved.getAllIndices().size() == 1) {
202+
return true;
203+
}
204+
}
205+
194206
try {
195207
boolean hasDlsRestrictions = !config.getDocumentPrivileges().isUnrestricted(context, resolved);
196208
boolean hasFlsRestrictions = !config.getFieldPrivileges().isUnrestricted(context, resolved);

0 commit comments

Comments
 (0)