Skip to content

feat: add support for mapping user admin status from OIDC claims - #1033

Open
UiP9AV6Y wants to merge 2 commits into
gotify:masterfrom
UiP9AV6Y:feature/oidc-claim-mapping
Open

feat: add support for mapping user admin status from OIDC claims#1033
UiP9AV6Y wants to merge 2 commits into
gotify:masterfrom
UiP9AV6Y:feature/oidc-claim-mapping

Conversation

@UiP9AV6Y

Copy link
Copy Markdown

an optional new configuration setting allows operators to define a JMESPath expression to calculate the admin status of a user based on their OIDC claims. this feature can also be used to deny users access alltogether, by mapping their claims to a special role value.

closes #957

@UiP9AV6Y
UiP9AV6Y requested a review from a team as a code owner August 20, 2026 19:40
Comment thread api/oidc.go Outdated

var roleExpression jmespath.JMESPath
if conf.OIDC.RoleExpression != "" {
roleExpression, err = jmespath.Compile(conf.OIDC.RoleExpression)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we need a full expression language here. Instead I propose three settings like this:

# OIDC ID-token claim containing the user's group memberships as a list of
# strings.
#
# Type: text
# GOTIFY_OIDC_GROUPS_CLAIM=groups

# Groups allowed to log in via OIDC. When set, users whose groups claim
# matches neither USER_GROUPS nor ADMIN_GROUPS are rejected. When empty,
# every user authenticated by the identity provider may log in.
#
# Type: text-list
# Example: messenger,gotify
# GOTIFY_OIDC_USER_GROUPS=

# OIDC groups whose members are granted admin rights.
# Membership is evaluated after each login.
#
# Type: text-list
# Example: admins,gotify-admins
# GOTIFY_OIDC_ADMIN_GROUPS=

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't think we need a full expression language here.

does that mean you are waiting for a second opinion or is that decision final? i am fine with the proposed changes, but wanted to clarify before i implement them.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

GOTIFY_OIDC_USER_GROUPS
GOTIFY_OIDC_ADMIN_GROUPS

shouldn't that be GOTIFY_OIDC_GROUPS_USER_ROLE and GOTIFY_OIDC_GROUPS_ADMIN_ROLE to follow the nested hierarchy nature of the config keys?

in v2 this would have looked like this:

oidc:
  groups:
    claim: groups
    user_role: [messenger, gotify]
    admin_role: [admins, gotify-admins]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does that mean you are waiting for a second opinion or is that decision final? i am fine with the proposed changes, but wanted to clarify before i implement them.

It's not final, you can tell your opinion, and give good points why a expression language is needed here. But if the three-setting solution is good enough that I'd prefer this.

shouldn't that be GOTIFY_OIDC_GROUPS_USER_ROLE and GOTIFY_OIDC_GROUPS_ADMIN_ROLE to follow the nested hierarchy nature of the config keys?

Good point, but I dislike the group and role in one name, as it basically describe the same thing. How about

GOTIFY_OIDC_GROUPS_CLAIM
GOTIFY_OIDC_GROUPS_USER
GOTIFY_OIDC_GROUPS_ADMIN

?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i have no strong opinion about using an expression languange. i have simply chosen this approach, as Grafana does the same. my personal deployment would also work with the simplified approach. this approach is also what other applications (e.g. ArgoCD) use for their mapping.

i have pushed a new commit with the refactored system. test and documentation have also been updated.

@UiP9AV6Y
UiP9AV6Y force-pushed the feature/oidc-claim-mapping branch from 21111f3 to 1cda078 Compare August 22, 2026 12:56
an optional new configuration setting allows operators to define
a JMESPath expression to calculate the admin status of a user
based on their OIDC claims. this feature can also be used to deny
users access alltogether, by mapping their claims to a special
role value.

closes gotify#957
instead of running the OIDC claims against a generic expression
evaluator (like Grafana does), we simple calculate the user
roles based on the group membership.

this is similar to how ArgoCD, ElasticSearch, and other perform
their permission mapping.
@UiP9AV6Y
UiP9AV6Y force-pushed the feature/oidc-claim-mapping branch from 1cda078 to 7c460e4 Compare August 22, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

OIDC: Map group claims to admin user flag

2 participants