Skip to content

Commit c59295f

Browse files
committed
Merge branch 'main' into multiple-resource-tests
2 parents 7067c3d + dcbaa1a commit c59295f

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2727
- Fix deprecated SSL transport settings in demo certificates ([#5723](https://github.com/opensearch-project/security/pull/5723))
2828
- 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))
2929
- [Performance] Call AdminDns.isAdmin once per request ([#5752](https://github.com/opensearch-project/security/pull/5752))
30+
- Update operations on `.kibana` system index now work correctly with Dashboards multi tenancy enabled. ([#5778](https://github.com/opensearch-project/security/pull/5778))
3031

3132
### Refactoring
3233
- [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/main/java/org/opensearch/sample/SampleResourceGroup.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import static org.opensearch.core.xcontent.ConstructingObjectParser.constructorArg;
2626
import static org.opensearch.core.xcontent.ConstructingObjectParser.optionalConstructorArg;
2727
import static org.opensearch.sample.utils.Constants.RESOURCE_GROUP_TYPE;
28-
import static org.opensearch.sample.utils.Constants.RESOURCE_TYPE;
2928

3029
/**
3130
* Sample resource group declared by this plugin.
@@ -45,7 +44,7 @@ public SampleResourceGroup(StreamInput in) throws IOException {
4544
}
4645

4746
private static final ConstructingObjectParser<SampleResourceGroup, Void> PARSER = new ConstructingObjectParser<>(
48-
RESOURCE_TYPE,
47+
RESOURCE_GROUP_TYPE,
4948
true,
5049
a -> {
5150
SampleResourceGroup s;
@@ -56,13 +55,15 @@ public SampleResourceGroup(StreamInput in) throws IOException {
5655
}
5756
s.setName((String) a[0]);
5857
s.setDescription((String) a[1]);
58+
// ignore a[2] as we know the type
5959
return s;
6060
}
6161
);
6262

6363
static {
6464
PARSER.declareString(constructorArg(), new ParseField("name"));
6565
PARSER.declareStringOrNull(optionalConstructorArg(), new ParseField("description"));
66+
PARSER.declareStringOrNull(optionalConstructorArg(), new ParseField("resource_type"));
6667
}
6768

6869
public static SampleResourceGroup fromXContent(XContentParser parser) throws IOException {

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
@@ -189,6 +189,18 @@ public boolean invoke(PrivilegesEvaluationContext context, final ActionListener<
189189
DlsFlsProcessedConfig config = this.dlsFlsProcessedConfig.get();
190190
IndexResolverReplacer.Resolved resolved = context.getResolvedRequest();
191191

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

src/main/java/org/opensearch/security/resources/ResourceIndexListener.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ public void postIndex(ShardId shardId, Engine.Index index, Engine.IndexResult re
7878
log.debug("postIndex called on {}", resourceIndex);
7979

8080
String resourceId = index.id();
81+
ResourceProvider provider = resourcePluginInfo.getResourceProvider(resourceType);
82+
if (provider == null) {
83+
log.warn(
84+
"Failed to create a resource sharing entry for resource: {} with type: {}. The type is not declared as a protected type in plugins.security.experimental.resource_sharing.protected_types.",
85+
resourceId,
86+
resourceType
87+
);
88+
return;
89+
}
8190

8291
// Only proceed if this was a create operation and for primary shard
8392
if (!index.origin().equals(Engine.Operation.Origin.PRIMARY)) {

0 commit comments

Comments
 (0)