Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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 @@ -176,15 +176,42 @@ private Map<String, Object> getRoleDescriptorMap(String key) {
// This following fixed role descriptor is for fleet-server BWC on and before 7.14.
// It is fixed and must NOT be updated when the fleet-server service account updates.
// Package private for testing
static final BytesArray FLEET_SERVER_ROLE_DESCRIPTOR_BYTES_V_7_14 = new BytesArray(
"{\"elastic/fleet-server\":{\"cluster\":[\"monitor\",\"manage_own_api_key\"],"
+ "\"indices\":[{\"names\":[\"logs-*\",\"metrics-*\",\"traces-*\",\"synthetics-*\","
+ "\".logs-endpoint.diagnostic.collection-*\"],"
+ "\"privileges\":[\"write\",\"create_index\",\"auto_configure\"],\"allow_restricted_indices\":false},"
+ "{\"names\":[\".fleet-*\"],\"privileges\":[\"read\",\"write\",\"monitor\",\"create_index\",\"auto_configure\"],"
+ "\"allow_restricted_indices\":false}],\"applications\":[],\"run_as\":[],\"metadata\":{},"
+ "\"transient_metadata\":{\"enabled\":true}}}"
);
static final BytesArray FLEET_SERVER_ROLE_DESCRIPTOR_BYTES_V_7_14 = new BytesArray("""
{
"elastic/fleet-server": {
"cluster": [ "monitor", "manage_own_api_key" ],
"indices": [
{
"names": [
"logs-*",
"metrics-*",
"traces-*",
"synthetics-*",
".logs-endpoint.diagnostic.collection-*"
],
"privileges": [ "write", "create_index", "auto_configure" ],
"allow_restricted_indices": false
},
{
"names": [ ".fleet-*" ],
"privileges": [
"read",
"write",
"monitor",
"create_index",
"auto_configure"
],
"allow_restricted_indices": false
}
],
"applications": [],
"run_as": [],
"metadata": {},
"transient_metadata": {
"enabled": true
}
}
}""");
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want this formatting?
We push those bytes around the cluster and store them in ThreadContext, what's the impact of a 25% increase in the size of the string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question. I just thought it looks nicer in this format and didn't think of other implications. We don't store it in threadContext or sent it across nodes. But we do parse RoleDescriptor from it and more importantly computing message digest for it. So I think it's better not to have the format.

One alternative to reverting the change is to add a call of .replaceAll("[\\n ]", "") at the end of the text block. So it can leverage the better looking format without paying most of the runtime cost. This approach is not very future proof. But since the value is meant to be immutable for this variable. It is not really a concern.

I am happy to just simply revert given the main purpose of this PR is to getting rid of unused variable. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

I decided to revert the format change.


private BytesReference getLimitedByRoleDescriptorsBytes() {
final BytesReference bytesReference = (BytesReference) metadata.get(API_KEY_LIMITED_ROLE_DESCRIPTORS_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,45 +200,6 @@ public class ApiKeyService {
Property.NodeScope
);

// This following fixed role descriptor is for fleet-server BWC on and before 7.14.
// It is fixed and must NOT be updated when the fleet-server service account updates.
private static final BytesArray FLEET_SERVER_ROLE_DESCRIPTOR_BYTES_V_7_14 = new BytesArray("""
{
"elastic/fleet-server": {
"cluster": [ "monitor", "manage_own_api_key" ],
"indices": [
{
"names": [
"logs-*",
"metrics-*",
"traces-*",
"synthetics-*",
".logs-endpoint.diagnostic.collection-*"
],
"privileges": [ "write", "create_index", "auto_configure" ],
"allow_restricted_indices": false
},
{
"names": [ ".fleet-*" ],
"privileges": [
"read",
"write",
"monitor",
"create_index",
"auto_configure"
],
"allow_restricted_indices": false
}
],
"applications": [],
"run_as": [],
"metadata": {},
"transient_metadata": {
"enabled": true
}
}
}""");

private final Clock clock;
private final Client client;
private final SecurityIndexManager securityIndex;
Expand Down