[Bug] OIDC login fails with HTTP 500 when a group has name: null (AttributeError in oidc_map_groups_to_role)
Describe the bug
Microsoft Entra ID, groups claim emitted as sAMAccountName or ID, PegaProx group mapping configured with group display names or ID, in all kind of combinations.
Cause: dict.get('name', '') only returns the default when the key is missing. If the key exists with value None, .lower() fails.
Fix:
group_names.add((g.get('name') or '').lower())
Steps to Reproduce
- After successful Entra ID login, POST /api/auth/oidc/callback returns 500.
- Browser shows a blank page or returns to the login page, where the Entra ID login button is missing.
- It takes several page reloads or empty cache to get the then missing Entra ID login button back on the login page.
Expected behavior
After clicking the "Sign in with Microsoft Entra ID" button, the user should be redirected to Microsoft's authentication dialog or if there is already a valid token provided, SSO should work and the user should find itself signed in with correct permissions. The role mapping should work minimum using the Object IDs of Entra ID groups for mapping so that login with subsequent PegaProx role assignment will happen.
Environment
- PegaProx Version: 1.1.1, 1.2.0 (works in 0.9.13.1)
- Installation Method: Deploy script
- OS: Debian 13.7 (trixie)
- Browser: Chrome 154.0.8037.58
- Behind Reverse Proxy? No
- UI? Corporate and Modern Layout
Logs
File "pegaprox/api/auth.py", line 215, in oidc_callback
role_mapping = oidc_map_groups_to_role(config, groups, id_claims, groups_complete=groups_complete)
File "pegaprox/utils/oidc.py", line 693, in oidc_map_groups_to_role
group_names.add(g.get('name', '').lower())
AttributeError: 'NoneType' object has no attribute 'lower'
Screenshots
Checklist
- [x] I have searched existing issues to make sure this is not a duplicate
- [x] I am using the latest version of PegaProx
- [x] I've put enough in here that someone can start on it without asking me three questions first
- [x] I understand PegaProx is maintained by volunteers in their free time. Nobody is on call, and writing URGENT doesn't get anyone out of bed 🪄
Thanks for the precise report and the suggested fix. Groups that Graph returns with a null display name no longer break the role mapping: ids and names are read null-safe and empty ones are skipped, so the OIDC callback no longer answers 500 and mapping by group object id works. This ships in 1.3.0.
(We're donation-funded, https://opencollective.com/pegaprox, in case that's an option for you.)
Marcus