Skip to content

Commit 35573c8

Browse files
author
BigPandaToo
committed
Support audit ignore policy by index privileges
Addressing review feedback
1 parent 697131c commit 35573c8

File tree

5 files changed

+129
-120
lines changed

5 files changed

+129
-120
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/ClusterPermission.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ public boolean check(final String action, final TransportRequest request, final
4747
return checks.stream().anyMatch(permission -> permission.check(action, request, authentication));
4848
}
4949

50-
/**
51-
* Checks permission to a cluster action.
52-
*
53-
* @param action cluster action
54-
* @return {@code true} if the specified action execution can be granted by given permission else returns {@code false}
55-
*/
56-
public boolean check(final String action) {
57-
return checks.stream().anyMatch(permission -> permission.check(action));
58-
}
59-
6050
/**
6151
* Checks if the specified {@link ClusterPermission}'s actions are implied by this {@link ClusterPermission}
6252
*
@@ -156,14 +146,6 @@ public interface PermissionCheck {
156146
*/
157147
boolean check(String action, TransportRequest request, Authentication authentication);
158148

159-
/**
160-
* Checks permission to a cluster action regardless of the request and authentication context.
161-
*
162-
* @param action action name
163-
* @return {@code true} if the specified action execution can be granted by given permission else returns {@code false}
164-
*/
165-
boolean check(String action);
166-
167149
/**
168150
* Checks whether specified {@link PermissionCheck} is implied by this {@link PermissionCheck}.<br>
169151
* This is important method to be considered during implementation as it compares {@link PermissionCheck}s.
@@ -196,11 +178,6 @@ public final boolean check(final String action, final TransportRequest request,
196178
return actionPredicate.test(action) && extendedCheck(action, request, authentication);
197179
}
198180

199-
@Override
200-
public final boolean check(final String action) {
201-
return actionPredicate.test(action);
202-
}
203-
204181
protected abstract boolean extendedCheck(String action, TransportRequest request, Authentication authentication);
205182

206183
@Override

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilegeResolver.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,20 +242,6 @@ public static Collection<String> findPrivilegesThatGrant(String action, Transpor
242242
.collect(Collectors.toUnmodifiableList());
243243
}
244244

245-
/**
246-
* Returns the names of privileges that grant the specified action.
247-
* @return A collection of names, ordered (to the extent possible) from least privileged (e.g. {@link #MONITOR})
248-
* to most privileged (e.g. {@link #ALL})
249-
* @see #sortByAccessLevel(Collection)
250-
* @see org.elasticsearch.xpack.core.security.authz.permission.ClusterPermission#check(String)
251-
*/
252-
public static Collection<String> findPrivilegesThatGrant(String action) {
253-
return VALUES.entrySet().stream()
254-
.filter(e -> e.getValue().permission().check(action))
255-
.map(Map.Entry::getKey)
256-
.collect(Collectors.toUnmodifiableList());
257-
}
258-
259245
/**
260246
* Sorts the collection of privileges from least-privilege to most-privilege (to the extent possible),
261247
* returning them in a sorted map keyed by name.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ManageOwnApiKeyClusterPrivilege.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ private ManageOwnClusterPermissionCheck() {
5757

5858
@Override
5959
protected boolean extendedCheck(String action, TransportRequest request, Authentication authentication) {
60+
if (request == null || authentication == null) {
61+
throw new IllegalArgumentException(
62+
"manage own cluster permission check only supported in context of request and authentication");
63+
}
64+
6065
if (request instanceof CreateApiKeyRequest) {
6166
return true;
6267
} else if (request instanceof GetApiKeyRequest) {

0 commit comments

Comments
 (0)