Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
11e955a
WIP CPS authz service
n1v0lg Sep 15, 2025
23ed699
WIP injection
n1v0lg Sep 15, 2025
ad8a9cb
Merge branch 'main' into cps-flat-world
n1v0lg Sep 15, 2025
ba24636
Index resolutions record resolved expressions
n1v0lg Sep 19, 2025
dd1dbe0
Smaller diff
n1v0lg Sep 19, 2025
a363c19
Clean up
n1v0lg Sep 19, 2025
103e044
Clean up
n1v0lg Sep 19, 2025
17c50c7
Another clean up round
n1v0lg Sep 19, 2025
8a5861c
Use a builder
n1v0lg Sep 19, 2025
777a8bc
Remove unused exclude
n1v0lg Sep 19, 2025
0474671
Nits
n1v0lg Sep 19, 2025
cbe0bd4
Bring back comment
n1v0lg Sep 19, 2025
8789cc4
Test ordering
n1v0lg Sep 19, 2025
820303b
Nits
n1v0lg Sep 19, 2025
7ba1eec
Order and TODO
n1v0lg Sep 19, 2025
bb79a5c
Debug order
n1v0lg Sep 19, 2025
aad05d6
Sets
n1v0lg Sep 19, 2025
457b45b
Remote also sets
n1v0lg Sep 19, 2025
013b1dd
Merge branch 'main' into record-local-index-resolution-results
n1v0lg Sep 20, 2025
a00b8cc
Merge branch 'main' into record-local-index-resolution-results
n1v0lg Sep 21, 2025
df37ed6
Merge branch 'main' into record-local-index-resolution-results
n1v0lg Sep 22, 2025
cb346e0
Tests
n1v0lg Sep 22, 2025
665bbec
[CI] Update transport version definitions
Sep 22, 2025
5ad94e4
Tweaks
n1v0lg Sep 22, 2025
845fd9f
Merge branch 'record-local-index-resolution-results' of github.com:n1…
n1v0lg Sep 22, 2025
97c6efa
More
n1v0lg Sep 22, 2025
62bb00f
Merge branch 'main' into record-local-index-resolution-results
n1v0lg Sep 23, 2025
add29c3
Toggle storage
n1v0lg Sep 23, 2025
1d0be73
Test
n1v0lg Sep 23, 2025
c15b0d7
Rm sysout
n1v0lg Sep 23, 2025
34c5c06
Merge branch 'main' into record-local-index-resolution-results
n1v0lg Sep 23, 2025
e2a0dff
Use hashset as optimization
n1v0lg Sep 24, 2025
893e0f4
Merge branch 'main' into record-local-index-resolution-results
n1v0lg Sep 24, 2025
177a8ac
Naming nits
n1v0lg Sep 24, 2025
f557655
Feedback
n1v0lg Sep 24, 2025
ad54ed1
Merge branch 'main' into record-local-index-resolution-results
n1v0lg Sep 24, 2025
df80b29
Merge branch 'record-local-index-resolution-results' into cps-flat-world
n1v0lg Sep 24, 2025
617d7d4
load project
n1v0lg Sep 24, 2025
63366dc
Merge branch 'main' into cps-flat-world
n1v0lg Sep 24, 2025
e2e6236
Tweaks
n1v0lg Sep 24, 2025
6354928
WIP
n1v0lg Sep 24, 2025
3be77da
Rename
n1v0lg Sep 24, 2025
115efe2
Merge branch 'main' into cps-flat-world
n1v0lg Sep 25, 2025
339ccea
Project filterting sort of works
n1v0lg Sep 25, 2025
eb3e45a
WIP resolve index
n1v0lg Sep 25, 2025
cfe91ef
[CI] Update transport version definitions
Sep 25, 2025
d39b249
More
n1v0lg Sep 25, 2025
46388a7
Merge branch 'cps-flat-world' of github.com:n1v0lg/elasticsearch into…
n1v0lg Sep 25, 2025
f1be6b4
Moar
n1v0lg Sep 25, 2025
515eb37
WIP plug in rewriting
n1v0lg Sep 25, 2025
6f79ff0
[CI] Update transport version definitions
Sep 25, 2025
cf76a8f
Plug in CPS rewrites
n1v0lg Sep 26, 2025
3b003ba
Merge
n1v0lg Sep 26, 2025
352711f
Go away transport
n1v0lg Sep 26, 2025
c41eebc
[CI] Update transport version definitions
Sep 26, 2025
2311e78
Merge branch 'main' into cps-flat-world
n1v0lg Sep 26, 2025
ae36d55
Transport will not go away
n1v0lg Sep 26, 2025
59ae6f2
Merge branch 'cps-flat-world' of github.com:n1v0lg/elasticsearch into…
n1v0lg Sep 26, 2025
0fe6504
Module info
n1v0lg Sep 26, 2025
9be4eba
Still module info
n1v0lg Sep 26, 2025
dcd3169
[CI] Auto commit changes from spotless
Sep 26, 2025
0338477
Fix
n1v0lg Sep 26, 2025
d58edf5
Merge branch 'cps-flat-world' of github.com:n1v0lg/elasticsearch into…
n1v0lg Sep 26, 2025
6f91def
Add error handling
n1v0lg Sep 26, 2025
ddc9e85
[CI] Update transport version definitions
Sep 26, 2025
6506e48
Tweak error handling
n1v0lg Sep 26, 2025
c30054b
Merge branch 'cps-flat-world' of github.com:n1v0lg/elasticsearch into…
n1v0lg Sep 26, 2025
55dc1c9
Fix up local index resolution
n1v0lg Sep 26, 2025
62d420f
Merge
n1v0lg Sep 26, 2025
b63c87e
Merge
n1v0lg Sep 29, 2025
4e65668
Tweaks
n1v0lg Sep 29, 2025
f75d465
Also xpack
n1v0lg Sep 29, 2025
a3bd85a
WIP debug wildcard weirdness
n1v0lg Sep 29, 2025
426832c
Dont overlog
n1v0lg Sep 29, 2025
6b8fc99
Set once
n1v0lg Sep 29, 2025
783e5a9
Nit
n1v0lg Sep 29, 2025
0390eca
Tweaks and fixes
n1v0lg Sep 30, 2025
5172e40
Merge
n1v0lg Sep 30, 2025
51cf6f7
Transport versions maybe
n1v0lg Sep 30, 2025
33b0341
Merge branch 'main' into cps-flat-world
n1v0lg Sep 30, 2025
607f465
Renames
n1v0lg Sep 30, 2025
c688e0a
Clean up authz project supplier
n1v0lg Sep 30, 2025
f4cd423
Merge
n1v0lg Sep 30, 2025
0af5abc
More clean up
n1v0lg Sep 30, 2025
1be3764
Clean up index resolution code
n1v0lg Oct 1, 2025
45bd995
More clean up
n1v0lg Oct 1, 2025
8f172a0
Clean up resolve index action
n1v0lg Oct 1, 2025
c9d793e
Smaller diff
n1v0lg Oct 1, 2025
040512c
More clean up
n1v0lg Oct 1, 2025
57c5f87
Tweaks
n1v0lg Oct 1, 2025
4454e32
Transport version check
n1v0lg Oct 1, 2025
ba12b8f
Transport version check
n1v0lg Oct 1, 2025
31ea357
Merge branch 'main' into cps-flat-world
n1v0lg Oct 1, 2025
43009ce
Merge branch 'main' into cps-flat-world
n1v0lg Oct 1, 2025
001a797
Merge branch 'cps-flat-world' of github.com:n1v0lg/elasticsearch into…
n1v0lg Oct 1, 2025
1c4ffe6
Nits
n1v0lg Oct 1, 2025
64aeef4
Clean up
n1v0lg Oct 2, 2025
ee80cb7
Feedback and validator
n1v0lg Oct 2, 2025
8be6bfd
Validator tweaks
n1v0lg Oct 2, 2025
4bccf95
Transport
n1v0lg Oct 2, 2025
5cb9214
Merge
n1v0lg Oct 2, 2025
3155355
[CI] Auto commit changes from spotless
Oct 2, 2025
c7a5477
Feedback
n1v0lg Oct 3, 2025
f57896a
Merge branch 'cps-flat-world' of github.com:n1v0lg/elasticsearch into…
n1v0lg Oct 3, 2025
5b5a7a9
Rename
n1v0lg Oct 3, 2025
407cffe
Helper
n1v0lg Oct 3, 2025
73ba8a9
More
n1v0lg Oct 3, 2025
7224d70
Merge
n1v0lg Oct 3, 2025
7240d89
[CI] Auto commit changes from spotless
Oct 3, 2025
395f3a0
Fix response code
n1v0lg Oct 3, 2025
39a50a4
Method
n1v0lg Oct 3, 2025
02e4693
Naming nit
n1v0lg Oct 3, 2025
1303b06
Early return
n1v0lg Oct 3, 2025
732ace0
Feedback
n1v0lg Oct 3, 2025
0537fa5
Merge branch 'main' into cps-flat-world
n1v0lg Oct 4, 2025
097a111
Clean up
n1v0lg Oct 4, 2025
e9f2f4e
Javadoc
n1v0lg Oct 5, 2025
c7748c2
Tweaks and renames
n1v0lg Oct 5, 2025
69c4a80
[CI] Auto commit changes from spotless
Oct 5, 2025
802671e
Merge branch 'main' into cps-flat-world
n1v0lg Oct 5, 2025
1044829
Merge branch 'cps-flat-world' of github.com:n1v0lg/elasticsearch into…
n1v0lg Oct 5, 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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_UUID_NA_VALUE;
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken;
import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureFieldName;
import static org.elasticsearch.search.crossproject.IndexExpressionsRewriter.NO_MATCHING_PROJECT_EXCEPTION_VERSION;
import static org.elasticsearch.search.crossproject.CrossProjectIndexExpressionsRewriter.NO_MATCHING_PROJECT_EXCEPTION_VERSION;

/**
* A base class for all elasticsearch exceptions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ default ResolvedIndexExpressions getResolvedIndexExpressions() {
default boolean allowsRemoteIndices() {
return false;
}

/**
* Determines whether the request type allows cross-project processing. Cross-project processing entails cross-project search
* index resolution and error handling. Note: this method only determines in the request _supports_ cross-project.
* Whether cross-project processing is actually performed is determined by {@link IndicesOptions}.
*/
default boolean allowsCrossProject() {
return false;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
package org.elasticsearch.action;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.core.Nullable;

import java.io.IOException;
import java.util.Set;

/**
Expand Down Expand Up @@ -40,7 +44,21 @@
* and failure info
* @param remoteExpressions the remote expressions that replace the original
*/
public record ResolvedIndexExpression(String original, LocalExpressions localExpressions, Set<String> remoteExpressions) {
public record ResolvedIndexExpression(String original, LocalExpressions localExpressions, Set<String> remoteExpressions)
implements
Writeable {

public ResolvedIndexExpression(StreamInput in) throws IOException {
this(in.readString(), new LocalExpressions(in), in.readCollectionAsImmutableSet(StreamInput::readString));
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(original);
localExpressions.writeTo(out);
out.writeStringCollection(remoteExpressions);
}

/**
* Indicates if a local index resolution attempt was successful or failed.
* Failures can be due to concrete resources not being visible (either missing or not visible due to indices options)
Expand All @@ -62,13 +80,28 @@ public record LocalExpressions(
Set<String> expressions,
LocalIndexResolutionResult localIndexResolutionResult,
@Nullable ElasticsearchException exception
) {
) implements Writeable {
public LocalExpressions {
assert localIndexResolutionResult != LocalIndexResolutionResult.SUCCESS || exception == null
: "If the local resolution result is SUCCESS, exception must be null";
}

// Singleton for the case where all expressions in a ResolvedIndexExpression instance are remote
public static final LocalExpressions NONE = new LocalExpressions(Set.of(), LocalIndexResolutionResult.NONE, null);

public LocalExpressions(StreamInput in) throws IOException {
this(
in.readCollectionAsImmutableSet(StreamInput::readString),
in.readEnum(LocalIndexResolutionResult.class),
ElasticsearchException.readException(in)
);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeStringCollection(expressions);
out.writeEnum(localIndexResolutionResult);
ElasticsearchException.writeException(exception, out);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@

package org.elasticsearch.action;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.action.ResolvedIndexExpression.LocalExpressions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand All @@ -20,50 +25,78 @@
/**
* A collection of {@link ResolvedIndexExpression}.
*/
public record ResolvedIndexExpressions(List<ResolvedIndexExpression> expressions) {
public record ResolvedIndexExpressions(List<ResolvedIndexExpression> expressions) implements Writeable {
public static final TransportVersion RESOLVED_INDEX_EXPRESSIONS = TransportVersion.fromName("resolved_index_expressions");

public ResolvedIndexExpressions(StreamInput in) throws IOException {
this(in.readCollectionAsImmutableList(ResolvedIndexExpression::new));
}

public List<String> getLocalIndicesList() {
return expressions.stream().flatMap(e -> e.localExpressions().expressions().stream()).toList();
}

public List<String> getRemoteIndicesList() {
return expressions.stream().flatMap(e -> e.remoteExpressions().stream()).toList();
}

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

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeCollection(expressions);
}

public static final class Builder {
private final List<ResolvedIndexExpression> expressions = new ArrayList<>();

/**
* Add a new resolved expression.
* @param original the original expression that was resolved -- may be blank for "access all" cases
* @param localExpressions is a HashSet as an optimization -- the set needs to be mutable, and we want to avoid copying it.
* May be empty.
*/
public void addLocalExpressions(
public void addExpressions(
String original,
HashSet<String> localExpressions,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Suggested change
HashSet<String> localExpressions,
Set<String> localExpressions,

Copy link
Contributor Author

@n1v0lg n1v0lg Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets defer that -- it's a HashSet because it needs to be modifiable for exclusion handling.

  • @param localExpressions is a HashSet as an optimization -- the set needs to be mutable, and we want to avoid copying it.

There are cleaner ways of doing this I'm sure but would prefer to follow it up in a separate PR.

ResolvedIndexExpression.LocalIndexResolutionResult resolutionResult
ResolvedIndexExpression.LocalIndexResolutionResult resolutionResult,
Set<String> remoteExpressions
) {
Objects.requireNonNull(original);
Objects.requireNonNull(localExpressions);
Objects.requireNonNull(resolutionResult);
Objects.requireNonNull(remoteExpressions);
expressions.add(
new ResolvedIndexExpression(original, new LocalExpressions(localExpressions, resolutionResult, null), new HashSet<>())
new ResolvedIndexExpression(original, new LocalExpressions(localExpressions, resolutionResult, null), remoteExpressions)
);
}

public void addRemoteExpressions(String original, Set<String> remoteExpressions) {
Objects.requireNonNull(original);
Objects.requireNonNull(remoteExpressions);
expressions.add(new ResolvedIndexExpression(original, LocalExpressions.NONE, remoteExpressions));
}

/**
* Exclude the given expressions from the local expressions of all prior added {@link ResolvedIndexExpression}.
*/
public void excludeFromLocalExpressions(Set<String> expressionsToExclude) {
Objects.requireNonNull(expressionsToExclude);
if (expressionsToExclude.isEmpty() == false) {
for (ResolvedIndexExpression prior : expressions) {
prior.localExpressions().expressions().removeAll(expressionsToExclude);
final Set<String> localExpressions = prior.localExpressions().expressions();
if (localExpressions.isEmpty()) {
continue;
}
localExpressions.removeAll(expressionsToExclude);
}
}
}

public ResolvedIndexExpressions build() {
// TODO make all sets on `expressions` immutable
return new ResolvedIndexExpressions(expressions);
}
}
Expand Down
Loading