-
Notifications
You must be signed in to change notification settings - Fork 713
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
Restrict APM Server user role #2777
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but deferring to the APM folks for approval.
@simitt @graphaelli should this role be builtin Elasticsearch, similar to the kibana user role? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, the monitoring privileges need to be applied to the .monitoring-beats-*
index though, and I think we can be more restrictive wrt Kibana privileges.
Just as information: with 7.6
we released experimental support of API Key auth for communication between APM agents and APM Server. The APM Server provides a CLI tool to manage such API Keys. The required privileges for that are the manage_api_key
on clusters, and adding specific APM application
privileges.
Since this API Key tooling needs manual interaction anyways, I think it is fair to not add the privileges here, and assume the users either provide a superuser
role when managing API Keys or add the privileges themselves.
UPDATE:
It is ok to not add the additional application
privileges, but manage_api_key
should be added to the cluster
privileges, as it is required for the APM Server verifying API keys created by another user.
// apmDefaultRoles are the default roles used by APM Server instances | ||
apmDefaultRoles = strings.Join([]string{ | ||
user.ApmDefaultUserRole, // Retrieve cluster details (e.g. version) and manage apm-* indices | ||
"kibana_user", // Load dependencies, such as example dashboards, if available, into Kibana |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For fetching agent remote config from Kibana the APM Server needs to have read+write access to apm indices, for which we should grant the built in apm_user
role rather than the more exhaustive kibana_user
afaik (cc @elastic/apm-ui).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The privileges required for agent configuration management I was referring to above, need to be set for the user talking to Kibana (apm-server.kibana
), but not for the elasticsearch
user.
Based on the explanation in https://github.com/elastic/cloud-on-k8s/pull/2777/files#r400078619 the apmDefaultRoles
will only be used for writing to ES. In this case no Kibana privileges are required for any APM Server >= 7.0, as dashboards are no longer shipped with the APM Server.
@elastic/apm-server for visibility |
apmDefaultRoles = strings.Join([]string{ | ||
user.ApmDefaultUserRole, // Retrieve cluster details (e.g. version) and manage apm-* indices | ||
"kibana_user", // Load dependencies, such as example dashboards, if available, into Kibana | ||
"ingest_admin", // Set up index templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand the difference between ApmDefaultUserRole
and this? It seems like we could put ingest_admin
in the cluster role def there along with monitor
and manage_ilm
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apmDefaultRoles
is a collection of roles which contain the role ApmDefaultUserRole
monitor
and manage_ilm
are privileges, while ingest_admin
is a built-in role.
I'm not sure we can mix a built-in role along with privileges ?
Same here, we still support 6.8. I would keep |
It is a little bit more complicated that what I thought :) Any attempt to start the APM server with a privilege that does not exist makes the request fail with something like:
If I understand correctly:
{
"cluster": ["manage_index_templates","monitor"],
"indices": [
{
"names": [ "apm-*" ],
"privileges": ["write","create_index"]
}
]
}
|
Not sure if that helps, but in our integration testing where we can start different versions inkl. 6.8 and early 7.x versions we use a user that has following custom role:
and also built-in roles |
This does not work for me. If I try to start an 6.8 APM Server with the
|
@barkbay you are right, I only checked that the server can start up. Since API Key handling is only an experimental feature and it seems to be the last blocking bit, I suggest to go ahead without this privilege for now. |
My understanding is that we need at least 2 different roles: one for v6 and an other v7, because of the The benefit of a third one for > 7.5 would be to add the I have no strong opinion but I think that if we have to manage 2 roles we can add a third one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all the effort you put into this. LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -18,12 +18,46 @@ const ( | |||
SuperUserBuiltinRole = "superuser" | |||
// ProbeUserRole is the name of the role used by the internal probe user. | |||
ProbeUserRole = "elastic_internal_probe_user" | |||
|
|||
// ApmUserRoleV6 is the name of the role used by the association user for 6.8.x APMServer instances. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we calling it the association user
? Is it not just the user APM Server will use to connect to Elasticsearch?
Thanks all for your help and the review 🙇 ! |
Fixes #2661
This PR:
default_apm_user_role
(name can be discussed ofc) to allow APM Server instances to setup and manageapm-*
indices:kibana_user
andingest_admin
I did some tests and it seems to work fine but I would be glad to have a quick review of the role by @simitt or @graphaelli. Thanks 🙇