grafana-operator icon indicating copy to clipboard operation
grafana-operator copied to clipboard

Set dashboards permissions through GrafanaDashboard CRD

Open DeanBrunt opened this issue 3 years ago • 10 comments

Is your feature request related to a problem? Please describe. Currently, I don't believe it's possible to set dashboard permissions using the GrafanaDashboard CRD. This would be a welcome enhancement for cases where users wish to provision dashboards with more granular permissions without having to set these up manually.

Describe the solution you'd like An addition to the GrafanaDashboard CRD that allows users to set permissions for a given team, role or user on the GrafanaDashboard.

Describe alternatives you've considered Manual permissions setup. It's a fine workaround but doesn't marry well with the model the operator strives for.

Additional context HTTP API does exist for managing this: https://grafana.com/docs/grafana/latest/http_api/dashboard_permissions/

DeanBrunt avatar Jul 01 '21 09:07 DeanBrunt

Would love to see this feature, there have also been talk about it on slack so I think other people would like it as well.

I do think we first need to start to support users & teams https://grafana.com/docs/grafana/latest/http_api/team/ and from there we can add this feature. Does that make sense?

NissesSenap avatar Jul 04 '21 08:07 NissesSenap

I do think we first need to start to support users & teams https://grafana.com/docs/grafana/latest/http_api/team/ and from there we can add this feature. Does that make sense?

I'm somewhat torn on this as it then gets complicated with some of the SSO models. I think you can get some good value by just implementing the dashboard permission modelling first (granted, yes, you have to effectively hardcode the users and teams) and leave manual/SSO sync for actual user and team provisioning. At least this way, if you need to roll out a new Grafana, you can hook up your SSO/LDAP/whatever and don't need to worry about provisioning dashboard perms.

DeanBrunt avatar Jul 05 '21 17:07 DeanBrunt

@DeanBrunt are the permissions necessarily tied to teams/organizations or can they work with only users? Also, do you know what the exact difference between organizations and users is?

pb82 avatar Jul 06 '21 12:07 pb82

@DeanBrunt are the permissions necessarily tied to teams/organizations or can they work with only users? Also, do you know what the exact difference between organizations and users is?

Permissions can be assigned to either roles (e.g: for 1 dashboard, a "Viewer" could have Edit access 🤯 ), teams or individual users.

In terms of organizations vs teams, I couldn't tell you the exact purpose of each, but I believe that teams exist within organizations.

DeanBrunt avatar Jul 08 '21 08:07 DeanBrunt

So i have read up on grafana rbac https://grafana.com/docs/grafana/latest/manage-users/

In short a user exist in grafana. That user can be a part of one or multiple organizations.

In a organization you can also have teams. A user can be part of one or multiple teams. You can assign access to teams.

A dashboard and a datasource exist within a organization.

In the operator when we create anything we just assume it's in organization Id 1, aka the default org.

Without creating any issues for us now or in the future i think we can implement access to specific dashboards by adding the feature to the grafan dashboard controller.

If we start support multiple organizations or teams in the future we shouldn't need to change much in this crd or even any.

We can even start to support setting team access on the dashboards if people add teams manually to there grafana insurances.

One of the painful things we need to solve is how to inform the users of the crd if the access is added to a user that actually exist. I think we can do this using the status field in the dashboard crd. Or we can just be lazy and say it's up to the user to provide the correct user uid and if you don't nothing will happen and they need to read about it in the operator logs. But that doesn't sound so user friendly.

Does this sound reasonable?

NissesSenap avatar Jul 13 '21 23:07 NissesSenap

@DeanBrunt this would require rewriting some of the dashboard management logic: you can't set the organization directly when creating / updating a dashboard. Instead you have to use a separate API to assign an organization to a dashboard. Additionally this API requires you to ontain and use the org's token. More details can be found here: https://grafana.com/docs/grafana/latest/http_api/dashboard/#create--update-dashboard

pb82 avatar Jul 27 '21 11:07 pb82

Our suggestion would be to close this issue in favor of a number of specific ones to address the rewrite of the account management. @DeanBrunt would you be available to join a triage call to discuss this further? We have a weekly one on Tuesdays at 1:30 CEST, but I'm also happy to find a time that works better for you.

pb82 avatar Jul 27 '21 11:07 pb82

Our suggestion would be to close this issue in favor of a number of specific ones to address the rewrite of the account management. @DeanBrunt would you be available to join a triage call to discuss this further? We have a weekly one on Tuesdays at 1:30 CEST, but I'm also happy to find a time that works better for you.

Yep that works for me. Just let me know the details of how to join etc

DeanBrunt avatar Jul 28 '21 10:07 DeanBrunt

@DeanBrunt would you still benefit from allowing to specify user and team IDs? The concern is that we make it user specific and later discover that supporting teams scales better.

pb82 avatar Aug 17 '21 12:08 pb82

This is very similar to other org config stuff. For this issue to move forward, we would need a design document first. From there, an implementation could possibly happen.

NissesSenap avatar Jul 09 '23 18:07 NissesSenap