Skip to content

Commit 6c56c32

Browse files
Grant necessary Kibana application privileges to reporting_user role (#118058)
Previously, Kibana was authorizing (and granting application privileges) to create reports, simply based on the `reporting_user` role name. This PR makes these application privileges explicitly granted to the `reporting_user` role.
1 parent 54e839b commit 6c56c32

File tree

4 files changed

+106
-15
lines changed

4 files changed

+106
-15
lines changed

docs/changelog/118058.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 118058
2+
summary: Grant necessary Kibana application privileges to `reporting_user` role
3+
area: Authorization
4+
type: enhancement
5+
issues: []

docs/reference/security/authorization/built-in-roles.asciidoc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,11 @@ Grants the minimum privileges required to write data into the monitoring indices
161161
Grants the minimum privileges required to collect monitoring data for the {stack}.
162162

163163
[[built-in-roles-reporting-user]] `reporting_user`::
164-
Grants the specific privileges required for users of {reporting} other than those
165-
required to use {kib}. This role grants access to the reporting indices; each
166-
user has access to only their own reports.
167-
Reporting users should also be assigned additional roles that grant
168-
{kibana-ref}/xpack-security-authorization.html[access to {kib}] as well as read
169-
access to the <<roles-indices-priv,indices>> that will be used to generate reports.
164+
Grants the necessary privileges required to use {reporting} features in {kib},
165+
including generating and downloading reports. This role implicitly grants access
166+
to all Kibana reporting features, with each user having access only to their own reports.
167+
Note that reporting users should also be assigned additional roles that grant read access
168+
to the <<roles-indices-priv,indices>> that will be used to generate reports.
170169

171170
[[built-in-roles-rollup-admin]] `rollup_admin`::
172171
Grants `manage_rollup` cluster privileges, which enable you to manage and execute all rollup actions.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,25 +301,40 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
301301
"Grants access to manage all index templates and all ingest pipeline configurations."
302302
)
303303
),
304-
// reporting_user doesn't have any privileges in Elasticsearch, and Kibana authorizes privileges based on this role
305304
entry(
306305
"reporting_user",
307306
new RoleDescriptor(
308307
"reporting_user",
309308
null,
310309
null,
310+
new RoleDescriptor.ApplicationResourcePrivileges[] {
311+
RoleDescriptor.ApplicationResourcePrivileges.builder()
312+
.application("kibana-.kibana")
313+
.resources("*")
314+
.privileges(
315+
"feature_discover.minimal_read",
316+
"feature_discover.generate_report",
317+
"feature_dashboard.minimal_read",
318+
"feature_dashboard.generate_report",
319+
"feature_dashboard.download_csv_report",
320+
"feature_canvas.minimal_read",
321+
"feature_canvas.generate_report",
322+
"feature_visualize.minimal_read",
323+
"feature_visualize.generate_report"
324+
)
325+
.build() },
311326
null,
312327
null,
313-
null,
314-
MetadataUtils.getDeprecatedReservedMetadata("Please use Kibana feature privileges instead"),
328+
MetadataUtils.DEFAULT_RESERVED_METADATA,
315329
null,
316330
null,
317331
null,
318332
null,
319-
"Grants the specific privileges required for users of X-Pack reporting other than those required to use Kibana. "
320-
+ "This role grants access to the reporting indices; each user has access to only their own reports. "
321-
+ "Reporting users should also be assigned additional roles that grant access to Kibana as well as read access "
322-
+ "to the indices that will be used to generate reports."
333+
"Grants the necessary privileges required to use reporting features in Kibana, "
334+
+ "including generating and downloading reports. "
335+
+ "This role implicitly grants access to all Kibana reporting features, "
336+
+ "with each user having access only to their own reports. Note that reporting users should also be assigned "
337+
+ "additional roles that grant read access to the indices that will be used to generate reports."
323338
)
324339
),
325340
entry(KibanaSystemUser.ROLE_NAME, kibanaSystemRoleDescriptor(KibanaSystemUser.ROLE_NAME)),

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,12 +2646,57 @@ public void testReportingUserRole() {
26462646
RoleDescriptor roleDescriptor = ReservedRolesStore.roleDescriptor("reporting_user");
26472647
assertNotNull(roleDescriptor);
26482648
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
2649-
assertThat(roleDescriptor.getMetadata(), hasEntry("_deprecated", true));
2649+
2650+
final String applicationName = "kibana-.kibana";
2651+
2652+
final Set<String> applicationPrivilegeNames = Set.of(
2653+
"feature_discover.minimal_read",
2654+
"feature_discover.generate_report",
2655+
"feature_dashboard.minimal_read",
2656+
"feature_dashboard.generate_report",
2657+
"feature_dashboard.download_csv_report",
2658+
"feature_canvas.minimal_read",
2659+
"feature_canvas.generate_report",
2660+
"feature_visualize.minimal_read",
2661+
"feature_visualize.generate_report"
2662+
);
2663+
2664+
final Set<String> allowedApplicationActionPatterns = Set.of(
2665+
"login:",
2666+
"app:discover",
2667+
"app:canvas",
2668+
"app:kibana",
2669+
"ui:catalogue/canvas",
2670+
"ui:navLinks/canvas",
2671+
"ui:catalogue/discover",
2672+
"ui:navLinks/discover",
2673+
"ui:navLinks/kibana",
2674+
"saved_object:index-pattern/*",
2675+
"saved_object:search/*",
2676+
"saved_object:query/*",
2677+
"saved_object:config/*",
2678+
"saved_object:config/get",
2679+
"saved_object:config/find",
2680+
"saved_object:config-global/*",
2681+
"saved_object:telemetry/*",
2682+
"saved_object:canvas-workpad/*",
2683+
"saved_object:canvas-element/*",
2684+
"saved_object:url/*",
2685+
"ui:discover/show"
2686+
);
2687+
2688+
final List<ApplicationPrivilegeDescriptor> applicationPrivilegeDescriptors = new ArrayList<>();
2689+
for (String appPrivilegeName : applicationPrivilegeNames) {
2690+
applicationPrivilegeDescriptors.add(
2691+
new ApplicationPrivilegeDescriptor(applicationName, appPrivilegeName, allowedApplicationActionPatterns, Map.of())
2692+
);
2693+
}
26502694

26512695
Role reportingUserRole = Role.buildFromRoleDescriptor(
26522696
roleDescriptor,
26532697
new FieldPermissionsCache(Settings.EMPTY),
2654-
RESTRICTED_INDICES
2698+
RESTRICTED_INDICES,
2699+
applicationPrivilegeDescriptors
26552700
);
26562701
assertThat(reportingUserRole.cluster().check(TransportClusterHealthAction.NAME, request, authentication), is(false));
26572702
assertThat(reportingUserRole.cluster().check(ClusterStateAction.NAME, request, authentication), is(false));
@@ -2723,6 +2768,33 @@ public void testReportingUserRole() {
27232768

27242769
assertNoAccessAllowed(reportingUserRole, TestRestrictedIndices.SAMPLE_RESTRICTED_NAMES);
27252770
assertNoAccessAllowed(reportingUserRole, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
2771+
2772+
applicationPrivilegeNames.forEach(appPrivilege -> {
2773+
assertThat(
2774+
reportingUserRole.application()
2775+
.grants(
2776+
ApplicationPrivilegeTests.createPrivilege(
2777+
applicationName,
2778+
appPrivilege,
2779+
allowedApplicationActionPatterns.toArray(new String[0])
2780+
),
2781+
"*"
2782+
),
2783+
is(true)
2784+
);
2785+
});
2786+
assertThat(
2787+
reportingUserRole.application()
2788+
.grants(
2789+
ApplicationPrivilegeTests.createPrivilege(
2790+
"kibana-.*",
2791+
"feature_random.minimal_read",
2792+
allowedApplicationActionPatterns.toArray(new String[0])
2793+
),
2794+
"*"
2795+
),
2796+
is(false)
2797+
);
27262798
}
27272799

27282800
public void testSuperuserRole() {

0 commit comments

Comments
 (0)