Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Document new role description field #108422

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2321425
[docs] Document new role description field
slobodanadamovic May 8, 2024
f92a7e3
update docs and add an example
slobodanadamovic May 10, 2024
3098c4e
Update get-role example
slobodanadamovic May 10, 2024
9b74009
Merge branch 'main' of github.com:elastic/elasticsearch into sa-role-…
slobodanadamovic May 10, 2024
f94210a
add description for built-in superuser role
slobodanadamovic May 10, 2024
fbd3b43
describe monitoring_user role
slobodanadamovic May 10, 2024
28c83bb
fix docs yaml smoketest
slobodanadamovic May 10, 2024
e31b95c
describe remote_monitoring_agent role
slobodanadamovic May 10, 2024
2c69025
spotless
slobodanadamovic May 10, 2024
e9b7a89
describe kibana_system role
slobodanadamovic May 10, 2024
3617dfa
break long description line
slobodanadamovic May 10, 2024
96995a2
spotless
slobodanadamovic May 10, 2024
0ab3bc1
remove testing API key role parsing wiith superuser role
slobodanadamovic May 10, 2024
443d721
fix failing test that depend on superuser role
slobodanadamovic May 10, 2024
d1b4cb1
fix failing API key integration test
slobodanadamovic May 10, 2024
8466efa
add description for remote_monitoring_collector role
slobodanadamovic May 10, 2024
294de37
add description for ingest_admin role
slobodanadamovic May 10, 2024
2aca219
reporting_user
slobodanadamovic May 10, 2024
24aa5f2
logstash_system
slobodanadamovic May 10, 2024
63bee73
beats_admin
slobodanadamovic May 10, 2024
c48e48a
beats_system
slobodanadamovic May 10, 2024
74005c1
apm_system
slobodanadamovic May 10, 2024
4264446
apm_user
slobodanadamovic May 10, 2024
ba5b614
inference_admin and inference_user
slobodanadamovic May 10, 2024
0365e04
machine_learning_user
slobodanadamovic May 10, 2024
42a11d2
machine_learning_admin and machine_learning_user
slobodanadamovic May 10, 2024
a25af8b
transform_admin and transform_user
slobodanadamovic May 10, 2024
80d1c24
viewer and editor
slobodanadamovic May 10, 2024
55425fe
enrich_user and snapshot_user
slobodanadamovic May 10, 2024
556d348
watcher_user and watcher_admin
slobodanadamovic May 10, 2024
df92e00
logstash_admin
slobodanadamovic May 10, 2024
ec31d8c
rollup_admin and rollup_user
slobodanadamovic May 10, 2024
3440fbf
kibana_admin (and kibana_user)
slobodanadamovic May 10, 2024
89e3c0f
data_frame_transforms_admin and data_frame_transforms_user
slobodanadamovic May 10, 2024
3fcd8f9
Merge branch 'main' of github.com:elastic/elasticsearch into sa-role-…
slobodanadamovic May 10, 2024
fa49a01
Apply suggestion
slobodanadamovic May 13, 2024
a80b061
Merge branch 'main' of github.com:elastic/elasticsearch into sa-role-…
slobodanadamovic May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,7 @@ setups['setup-snapshots'] = setups['setup-repository'] + '''
name: "my_admin_role"
body: >
{
"description": "Grants full access to all management features within the cluster.",
"cluster": ["all"],
"indices": [
{"names": ["index1", "index2" ], "privileges": ["all"], "field_security" : {"grant" : [ "title", "body" ]}}
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/rest-api/security/create-roles.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ privilege or action.
`cluster`:: (list) A list of cluster privileges. These privileges define the
cluster level actions that users with this role are able to execute.

`description`:: (string) A description of the role.
The maximum length is `1000` chars.
kc13greiner marked this conversation as resolved.
Show resolved Hide resolved
slobodanadamovic marked this conversation as resolved.
Show resolved Hide resolved

`global`:: (object) An object defining global privileges. A global privilege is
a form of cluster privilege that is request-aware. Support for global privileges
is currently limited to the management of application privileges.
Expand Down Expand Up @@ -104,6 +107,7 @@ The following example adds a role called `my_admin_role`:
--------------------------------------------------
POST /_security/role/my_admin_role
{
"description": "Grants full access to all management features within the cluster.",
"cluster": ["all"],
"indices": [
{
Expand Down
1 change: 1 addition & 0 deletions docs/reference/rest-api/security/get-roles.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ GET /_security/role/my_admin_role
--------------------------------------------------
{
"my_admin_role": {
"description": "Grants full access to all management features within the cluster.",
"cluster" : [ "all" ],
"indices" : [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ static RoleDescriptor kibanaAdminUser(String name, Map<String, Object> metadata)
null,
null,
metadata,
null
null,
null,
null,
null,
"Grants access to all features in Kibana."
);
}

Expand Down Expand Up @@ -408,7 +412,13 @@ static RoleDescriptor kibanaSystem(String name) {
getRemoteIndicesReadPrivileges("traces-apm-*") },
null,
null,
null
"Grants access necessary for the Kibana system user to read from and write to the Kibana indices, "
+ "manage index templates and tokens, and check the availability of the Elasticsearch cluster. "
+ "It also permits activating, searching, and retrieving user profiles, "
+ "as well as updating user profile data for the kibana-* namespace. "
+ "Additionally, this role grants read access to the .monitoring-* indices "
+ "and read and write access to the .reporting-* indices. "
+ "Note: This role should not be assigned to users as the granted permissions may change between releases."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a verbatim copy of kibana_system role's description. The documentation seems to be outdated, since the permissions have changed quite a lot since the documentation was first written.
Not sure if we should cover them all. But I do think it's worth revisiting description to be more explicit in stating that this its intention is for system use by Kibana and that it should not be granted to regular users.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good catch! I can take this back to my team to discuss updates, but I think this is fine for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me.

);
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,9 @@ public void testUpdateApiKeysAutoUpdatesLegacySuperuserRoleDescriptor() throws E
// raw document has the legacy superuser role descriptor
expectRoleDescriptorsForApiKey("limited_by_role_descriptors", legacySuperuserRoleDescriptor, getApiKeyDocument(apiKeyId));

final Set<RoleDescriptor> currentSuperuserRoleDescriptors = Set.of(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR);
final Set<RoleDescriptor> currentSuperuserRoleDescriptors = ApiKeyService.removeUserRoleDescriptorDescriptions(
Set.of(ReservedRolesStore.SUPERUSER_ROLE_DESCRIPTOR)
);
// The first request is not a noop because we are auto-updating the legacy role descriptors to 8.x role descriptors
assertSingleUpdate(
apiKeyId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,13 @@ && hasRemoteIndices(request.getRoleDescriptors())) {
}
}

private Set<RoleDescriptor> removeUserRoleDescriptorDescriptions(Set<RoleDescriptor> userRoleDescriptors) {
/**
* This method removes description from the given user's (limited-by) role descriptors.
* The description field is not supported for API key role descriptors hence storing limited-by roles with descriptions
* would be inconsistent and require handling backwards compatibility.
* Hence why we have to remove them before create/update of API key roles.
*/
static Set<RoleDescriptor> removeUserRoleDescriptorDescriptions(Set<RoleDescriptor> userRoleDescriptors) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made package protected for testing.

return userRoleDescriptors.stream().map(roleDescriptor -> {
if (roleDescriptor.hasDescription()) {
return new RoleDescriptor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,9 @@ private static Tuple<Map<String, Object>, Map<String, Object>> newApiKeyDocument
getFastStoredHashAlgoForTests().hash(new SecureString(key.toCharArray())),
"test",
authentication,
type == ApiKey.Type.CROSS_CLUSTER ? Set.of() : Collections.singleton(SUPERUSER_ROLE_DESCRIPTOR),
type == ApiKey.Type.CROSS_CLUSTER
? Set.of()
: ApiKeyService.removeUserRoleDescriptorDescriptions(Set.of(SUPERUSER_ROLE_DESCRIPTOR)),
Instant.now(),
Instant.now().plus(expiry),
keyRoles,
Expand Down Expand Up @@ -1316,22 +1318,6 @@ public void testParseRoleDescriptorsMap() throws Exception {
assertThat(roleDescriptors, hasSize(1));
assertThat(roleDescriptors.get(0), equalTo(roleARoleDescriptor));

Map<String, Object> superUserRdMap;
try (XContentBuilder builder = JsonXContent.contentBuilder()) {
superUserRdMap = XContentHelper.convertToMap(
XContentType.JSON.xContent(),
BytesReference.bytes(SUPERUSER_ROLE_DESCRIPTOR.toXContent(builder, ToXContent.EMPTY_PARAMS, true)).streamInput(),
false
);
}
roleDescriptors = service.parseRoleDescriptors(
apiKeyId,
Map.of(SUPERUSER_ROLE_DESCRIPTOR.getName(), superUserRdMap),
randomApiKeyRoleType()
);
assertThat(roleDescriptors, hasSize(1));
assertThat(roleDescriptors.get(0), equalTo(SUPERUSER_ROLE_DESCRIPTOR));

final Map<String, Object> legacySuperUserRdMap;
try (XContentBuilder builder = JsonXContent.contentBuilder()) {
legacySuperUserRdMap = XContentHelper.convertToMap(
Expand Down Expand Up @@ -1812,7 +1798,10 @@ public void testApiKeyDocCache() throws IOException, ExecutionException, Interru
RoleReference.ApiKeyRoleType.LIMITED_BY
);
assertEquals(1, limitedByRoleDescriptors.size());
assertEquals(SUPERUSER_ROLE_DESCRIPTOR, limitedByRoleDescriptors.get(0));
RoleDescriptor superuserWithoutDescription = ApiKeyService.removeUserRoleDescriptorDescriptions(Set.of(SUPERUSER_ROLE_DESCRIPTOR))
.iterator()
.next();
assertEquals(superuserWithoutDescription, limitedByRoleDescriptors.get(0));
if (metadata == null) {
assertNull(cachedApiKeyDoc.metadataFlattened);
} else {
Expand Down