问题描述
我的小组正在使用Prometheus运算符图表中的Grafana https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L486
Grafana正在运行,我们可以使用Oauth进行访问。 现在,我们在OAuth OIDC服务器中定义了一个角色,我们需要在Grafana中定义(并接受),每个用户都将根据OAuth服务器定义来获得其角色。
例如角色“ UserViewer”
我应该如何在Grafana中对其进行配置? 我看到了这个https://grafana.com/docs/grafana/latest/auth/generic-oauth/#role-mapping,但没有说明图表的安装。知道如何配置角色吗?
如果有人知道如何在Grafana图表上对其进行配置,我的意思是我应该如何传递此角色json。归档将很有帮助 https://github.com/grafana/helm2-grafana
除了掌控用户(开发人员)以验证角色是否已添加到令牌之外,我该如何使用掌舵功能(使用配置更新舞会图)。
解决方法
修改grafana.ini
,例如(语法可能是错误的,只是为了告诉您想法):
helm install \
-f values.yaml \
--set grafana."grafana\.ini"."auth\.generic_oauth".role_attribute_path=contains(info.groups[*],'admin') && 'Admin' || contains(info.groups[*],'editor') && 'Editor' || 'Viewer'
...
或直接在使用的values.yaml中。当然,role_attribute_path
对于您的用例(角色声明名称,组名称等)必须是有效的配置。
请记住,the token has the role
可能无法正常工作-请参见https://github.com/grafana/grafana/issues/23218。经过身份验证的用户将至少具有Viewer
角色。如果您确实需要“拒绝行为”,则可以使用其他方法(例如将执行身份验证和授权的自定义身份验证代理,以及Auth Proxy
模式下的Grafana)