Skip to content

Commit f143685

Browse files
include index name in exception message
1 parent 9d89502 commit f143685

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/AuthorizationService.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,17 @@ private void handleIndexActionAuthorizationResult(
717717
if (indexExpressions != null) {
718718
indexExpressions.expressions().forEach(resolved -> {
719719
if (resolved.localExpressions().localIndexResolutionResult() == CONCRETE_RESOURCE_UNAUTHORIZED) {
720-
resolved.localExpressions().setException(actionDenied(authentication, authzInfo, action, request));
720+
resolved.localExpressions()
721+
.setException(
722+
actionDenied(
723+
authentication,
724+
authzInfo,
725+
action,
726+
request,
727+
IndexAuthorizationResult.getFailureDescription(List.of(resolved.original()), restrictedIndices),
728+
null
729+
)
730+
);
721731
}
722732
});
723733
}

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3899,7 +3899,8 @@ public void testSetExceptionOnMissingIndexWhenIgnoreUnavailable() {
38993899
assertThat(
39003900
expressions.get(1).localExpressions().exception().getMessage(),
39013901
equalTo(
3902-
"action [indices:data/read/search] is unauthorized for user [user] with effective roles [partial-access-role], "
3902+
"action [indices:data/read/search] is unauthorized for user [user]" +
3903+
" with effective roles [partial-access-role] on indices [not-available-index], "
39033904
+ "this action is granted by the index privileges [read,all]"
39043905
)
39053906
);

0 commit comments

Comments
 (0)