Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b90165e
resolve expressions from role per group
jakelandis Jan 22, 2025
7b2d256
fix variable shadow
jakelandis Jan 22, 2025
5b15f40
basic manual tests pass
jakelandis Jan 22, 2025
eb45a0d
assertions and comments
jakelandis Jan 23, 2025
f02d184
wildcard in role mostly working (test*::*) still fails
jakelandis Jan 23, 2025
6270503
fixed wildcard in role (i think)
jakelandis Jan 23, 2025
f2e45a2
spotless and precommit
jakelandis Jan 23, 2025
445ba6d
don't support hasPrivileges for failure restrictions (still need vali…
jakelandis Jan 23, 2025
cbfedd1
clean up and organize thoughts (comment on direction change)
jakelandis Jan 24, 2025
37821a8
refactor to only support ::failures (simple cases work, but doing unc…
jakelandis Jan 24, 2025
bb90832
greatly simplify
jakelandis Jan 24, 2025
4e86384
nits
jakelandis Jan 24, 2025
9893ccf
[CI] Auto commit changes from spotless
Jan 24, 2025
a5b6d14
handle deny of .fs* indices
jakelandis Jan 25, 2025
f3f7eca
Merge remote-tracking branch 'upstream/main' into alt_119915_hack
jakelandis Jan 25, 2025
fb18a5f
Merge remote-tracking branch 'upstream/main' into alt_119915_hack
jakelandis Jan 28, 2025
c8e9fd6
fix tests that expect failure store indices to be authorized
jakelandis Jan 28, 2025
01e7add
minor clean up
jakelandis Jan 28, 2025
2a544b6
[CI] Auto commit changes from spotless
Jan 28, 2025
03a1591
fix parathensis bug
jakelandis Jan 29, 2025
7944d60
fix test and minor clean up
jakelandis Jan 29, 2025
337f6e1
minor clean up and test fix
jakelandis Jan 29, 2025
4fd53cd
fix direct access to .fs and .ds indices
jakelandis Jan 30, 2025
81f32a9
Merge remote-tracking branch 'upstream/main' into alt_119915_hack
jakelandis Jan 30, 2025
dc5eaf5
initial black box test (copied from Nikolaj's PoC)
jakelandis Jan 31, 2025
b34965d
[CI] Auto commit changes from spotless
Jan 31, 2025
7077de9
support has privs
jakelandis Jan 31, 2025
56a8c76
Merge remote-tracking branch 'upstream/main' into alt_119915_hack
jakelandis Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/plugin/core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
requires unboundid.ldapsdk;
requires org.elasticsearch.tdigest;
requires org.elasticsearch.xcore.templates;
requires org.elasticsearch.logging;

exports org.elasticsearch.index.engine.frozen;
exports org.elasticsearch.license;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@

import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.IndexComponentSelector;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.xpack.core.security.authz.AuthorizationEngine;
import org.elasticsearch.xpack.core.security.authz.RoleDescriptor.ApplicationResourcePrivileges;
import org.elasticsearch.xpack.core.security.authz.RoleDescriptor.IndicesPrivileges;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
* A request for checking a user's privileges
Expand Down Expand Up @@ -84,7 +89,50 @@ public ApplicationResourcePrivileges[] applicationPrivileges() {
}

public void indexPrivileges(IndicesPrivileges... privileges) {
this.indexPrivileges = privileges;
IndicesPrivileges[] newPrivileges = new IndicesPrivileges[privileges.length];
for (int i = 0; i < privileges.length; i++) {
IndicesPrivileges currentPriv = privileges[i];
IndicesPrivileges.Builder builder = IndicesPrivileges.builder(privileges[i]);
builder.indices((String[]) null);
List<String> updatedIndexPatterns = new ArrayList<>();
for (String indexPatternRequested : currentPriv.getIndices()) {
Tuple<String, String> split = IndexNameExpressionResolver.splitSelectorExpression(indexPatternRequested);
String indexNameNoSelector = split.v1();
String selectorAsString = split.v2();
if (selectorAsString == null) {
assert indexPatternRequested.equals(indexNameNoSelector);
updatedIndexPatterns.add(indexNameNoSelector); // add as-is, no selector
} else {
IndexComponentSelector selector = IndexComponentSelector.getByKey(selectorAsString);
switch (selector) {
case DATA:
updatedIndexPatterns.add(indexNameNoSelector); // strip the selector
break;
case FAILURES:
updatedIndexPatterns.add(indexPatternRequested); // add as-is, keep selector in name
break;
case ALL_APPLICABLE:
updatedIndexPatterns.add(indexNameNoSelector); // add with no selector for data
updatedIndexPatterns.add(
IndexNameExpressionResolver.combineSelector(indexNameNoSelector, IndexComponentSelector.FAILURES)
); // add with failure selector
break;
default:
throw new IllegalArgumentException(
"Unknown index component selector ["
+ selectorAsString
+ "], available options are: "
+ IndexComponentSelector.values()
);

}
}
builder.indices(updatedIndexPatterns);
newPrivileges[i] = builder.build();
}
}

this.indexPrivileges = newPrivileges;
}

public void clusterPrivileges(String... privileges) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,10 @@ public static Builder builder() {
return new Builder();
}

public static Builder builder(IndicesPrivileges copyFrom) {
return new Builder(copyFrom);
}

public String[] getIndices() {
return this.indices;
}
Expand Down Expand Up @@ -1553,6 +1557,15 @@ public static class Builder {

private Builder() {}

private Builder(IndicesPrivileges copyFrom) {
indicesPrivileges.indices = copyFrom.indices;
indicesPrivileges.privileges = copyFrom.privileges;
indicesPrivileges.grantedFields = copyFrom.grantedFields;
indicesPrivileges.deniedFields = copyFrom.deniedFields;
indicesPrivileges.query = copyFrom.query;
indicesPrivileges.allowRestrictedIndices = copyFrom.allowRestrictedIndices;
}

public Builder indices(String... indices) {
indicesPrivileges.indices = indices;
return this;
Expand Down
Loading