- What Grafana version and what operating system are you using?
10.4
- What are you trying to achieve?
okta authentication, group-based and attribute-based role
- How are you trying to achieve it?
role_attribute_path: “(contains(groups[*], ‘Dept_X’) && data.attribute1 == ‘true’) && ‘GrafanaAdmin’ || ‘None’”
- What happened?
I get the None condition
- What did you expect to happen?
This is where things get interesting. I’m trying to do a combination of group membership and a user-level attribute equaling a value as the conditional decision. The idea is that we are doing using a single group, say for a bunch of devs, but we only want them to have access when a given attribute matches a value - eg more than simple group membership.
I’ve experimented with the stanza on jmespath.org - here is the query and (dummy) data for validation:
query: (contains(groups[*], 'Dept_X') && attributes.key1 == 'true') && 'GrafanaAdmin' || 'None'
data block:
{
"groups": [
"abc",
"Dept_X"
],
"attributes": {
"attribute1": "x",
"attribute2": "val2"
}
}
If you change the value of attribute1 from “x” to “true” the result will change to GrafanaAdmin like it should
The part I am missing is how to access the custom user attribute key in the spath condition. I have set the log level of grafana to debug and I see (sorry, doctored a bit, reformatted for ease of reading)
logger=oauth.okta t=2025-03-27T18:33:24.969204252Z level=debug msg="Received user info response"
raw_json="{
"sub":"xxxx",
"name":"xxxx",
"locale":"en_US",
"email":"xxxx",
"preferred_username":"xxxx",
"given_name":"xxx",
"family_name":"xxx",
"zoneinfo":"AmericagLos_Angeles",
"updated_at":1234,
"email_verified":true,
"groups":[
"Everyone",
(... snip )
"Dept_X"
]
}"
data="unsupported value type"
I’m hoping the attributes are buried somewhere in data. I can’t see the value so its hard to know what to key off of.
If I take the attribute bit out of the spath authentication works and I get the appropriate role so this is not an issue with the grafana / okta configuration.
- Did you follow any online instructions? If so, what is the URL?