Skip to content

Commit e4da221

Browse files
Updates DlsFlsValveImpl condition to return true if request is internal and not a protected resource request (#5721)
Signed-off-by: Darshit Chanpura <[email protected]>
1 parent 20ebf22 commit e4da221

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1515
- Create a WildcardMatcher.NONE when creating a WildcardMatcher with an empty string ([#5694](https://github.com/opensearch-project/security/pull/5694))
1616
- Improve array validator to also check for blank string in addition to null ([#5714](https://github.com/opensearch-project/security/pull/5714))
1717
- Use RestRequestFilter.getFilteredRequest to declare sensitive API params ([#5710](https://github.com/opensearch-project/security/pull/5710))
18-
18+
- 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))
1919

2020
### Refactoring
2121
- [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))

sample-resource-plugin/src/integrationTest/java/org/opensearch/sample/resource/feature/enabled/ExcludedResourceTypeTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,25 @@ public void testSampleResourceSharingIndexExists() {
7070
public void fullAccessUser_canCRUD() {
7171
api.assertApiGet(resourceId, FULL_ACCESS_USER, HttpStatus.SC_OK, "sample");
7272
api.assertApiUpdate(resourceId, FULL_ACCESS_USER, "sampleUpdateAdmin", HttpStatus.SC_OK);
73+
api.assertApiGetSearch(FULL_ACCESS_USER, HttpStatus.SC_OK, 1, "sample");
74+
api.createSampleResourceAs(FULL_ACCESS_USER);
75+
api.assertApiGetSearch(FULL_ACCESS_USER, HttpStatus.SC_OK, 2, "sample");
7376
api.assertApiDelete(resourceId, FULL_ACCESS_USER, HttpStatus.SC_OK);
7477
}
7578

7679
@Test
7780
public void limitedAccessUser_canCRUD() {
7881
api.assertApiGet(resourceId, LIMITED_ACCESS_USER, HttpStatus.SC_OK, "sample");
7982
api.assertApiUpdate(resourceId, LIMITED_ACCESS_USER, "sampleUpdateAdmin", HttpStatus.SC_FORBIDDEN);
83+
api.assertApiGetSearch(LIMITED_ACCESS_USER, HttpStatus.SC_OK, 1, "sample");
8084
api.assertApiDelete(resourceId, LIMITED_ACCESS_USER, HttpStatus.SC_FORBIDDEN);
8185
}
8286

8387
@Test
8488
public void noAccessUser_canCRUD() {
8589
api.assertApiGet(resourceId, NO_ACCESS_USER, HttpStatus.SC_FORBIDDEN, "");
8690
api.assertApiUpdate(resourceId, NO_ACCESS_USER, "sampleUpdateAdmin", HttpStatus.SC_FORBIDDEN);
91+
api.assertApiGetSearchForbidden(NO_ACCESS_USER);
8792
api.assertApiDelete(resourceId, NO_ACCESS_USER, HttpStatus.SC_FORBIDDEN);
8893
}
8994
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,11 @@ public boolean invoke(PrivilegesEvaluationContext context, final ActionListener<
163163
}
164164
ActionRequest request = context.getRequest();
165165
if (HeaderHelper.isInternalOrPluginRequest(threadContext)) {
166-
IndexResolverReplacer.Resolved resolved = context.getResolvedRequest();
167166
if (resourceSharingEnabledSetting.getDynamicSettingValue() && request instanceof SearchRequest) {
168-
167+
IndexResolverReplacer.Resolved resolved = context.getResolvedRequest();
169168
Set<String> protectedIndices = resourcePluginInfo.getResourceIndicesForProtectedTypes();
170169
WildcardMatcher resourceIndicesMatcher = WildcardMatcher.from(protectedIndices);
171170
if (resourceIndicesMatcher.matchAll(resolved.getAllIndices())) {
172-
173171
IndexToRuleMap<DlsRestriction> sharedResourceMap = ResourceSharingDlsUtils.resourceRestrictions(
174172
namedXContentRegistry,
175173
resolved,
@@ -187,9 +185,8 @@ public boolean invoke(PrivilegesEvaluationContext context, final ActionListener<
187185
threadContext
188186
);
189187
}
190-
} else {
191-
return true;
192188
}
189+
return true;
193190
}
194191
DlsFlsProcessedConfig config = this.dlsFlsProcessedConfig.get();
195192
IndexResolverReplacer.Resolved resolved = context.getResolvedRequest();

0 commit comments

Comments
 (0)