Conversation
Contributor
There was a problem hiding this comment.
Issues Found
No issues found.
Summary
Total issues: 0 critical, 0 important, 0 minor.
Overall Verdict
Status: Patch is correct
Explanation: Reviewed the PR diff for OIDC claim-based role mapping: role resolution, settings validation, schema default, and new settings endpoints are internally consistent and do not introduce obvious runtime errors or security regressions. The new mapping evaluation and validation logic appears safe for nil/empty cases and preserves existing default-role behavior when no mapping matches.
Review generated by Hodor (model: gpt-5.2)
Review Metrics — 17 turns, 16 tool calls, 2m 45s
- Tokens: in
24.6K| cached310.8K| out12.2K(total347.5K) - Cost:
$0.2676
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds configurable OIDC claim-based role mapping for newly auto-created users.
It allows listmonk to assign
user_role_idand/orlist_role_idbased on top-level claims present in the verified OIDC ID token.The existing default OIDC roles remain the fallback when no mapping matches.
Motivation
OIDC auto-created users currently receive only the configured default user and list roles.
In environments where the identity provider already exposes authorization-related attributes, such as groups or departments, administrators may need newly created users to receive different listmonk roles based on those claims.
This PR adds a generic provider-independent mapping mechanism without introducing provider-specific logic.
Behavior
Mappings are evaluated in declaration order.
The first matching mapping wins.
Supported claim value types are:
Matching is exact and case-sensitive.
Example:
[ { "claim": "groups", "match": "listmonk-admin", "user_role_id": 1 }, { "claim": "department", "match": "AN", "user_role_id": 5, "list_role_id": 6 } ]For an ID token containing:
{ "groups": [ "users", "listmonk-admin" ], "department": "AN" }the first mapping matches and wins.
If a mapping defines only one role type, the configured default is preserved for the other role.
If no mapping matches, the existing OIDC default user and list roles are used.
Scope
Mappings are applied only when an unknown OIDC user is automatically created.
Existing users are not resynchronized on subsequent logins, even if their OIDC claims change.
This preserves the current behavior for existing accounts.
API
Two authenticated endpoints are added:
The GET endpoint requires:
The PUT endpoint requires:
The PUT endpoint validates:
claimmatchuser_role_idorlist_role_idInvalid mappings return HTTP 400 and do not modify the current configuration.
The generic settings update path also preserves mappings when older clients do not send the
role_mappingsfield, and validates mappings when they are present.Backward compatibility
Existing installations without a
role_mappingsproperty continue to work unchanged.For new installations, the default OIDC settings include:
"role_mappings": []When no mappings are configured, OIDC auto-creation behaves exactly as before.
Implementation
The change:
No frontend changes are included.
Testing
Tested against the current
masterafter rebasing.Automated tests cover:
Manual end-to-end testing covered:
Build and targeted tests pass on the rebased branch.