mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-06 19:06:02 +03:00
OIDC: Distributed claims are not retrieved during group sync #5213
Open
opened 2026-02-05 09:48:49 +03:00 by OVERLORD
·
7 comments
No Branch/Tag Specified
development
further_theme_development
l10n_development
release
llm_only
vectors
v25-11
docker_env
drawio_rendering
user_permissions
ldap_host_failover
svg_image
prosemirror
captcha_example
fix/video-export
v25.12.3
v25.12.2
v25.12.1
v25.12
v25.11.6
v25.11.5
v25.11.4
v24.11.4
v25.11.3
v25.11.2
v25.11.1
v25.11
v25.07.3
v25.07.2
v25.07.1
v25.07
v25.05.2
v25.05.1
v25.05
v25.02.5
v25.02.4
v25.02.3
v25.02.2
v25.02.1
v25.02
v24.12.1
v24.12
v24.10.3
v24.10.2
v24.10.1
v24.10
v24.05.4
v24.05.3
v24.05.2
v24.05.1
v24.05
v24.02.3
v24.02.2
v24.02.1
v24.02
v23.12.3
v23.12.2
v23.12.1
v23.12
v23.10.4
v23.10.3
v23.10.2
v23.10.1
v23.10
v23.08.3
v23.08.2
v23.08.1
v23.08
v23.06.2
v23.06.1
v23.06
v23.05.2
v23.05.1
v23.05
v23.02.3
v23.02.2
v23.02.1
v23.02
v23.01.1
v23.01
v22.11.1
v22.11
v22.10.2
v22.10.1
v22.10
v22.09.1
v22.09
v22.07.3
v22.07.2
v22.07.1
v22.07
v22.06.2
v22.06.1
v22.06
v22.04.2
v22.04.1
v22.04
v22.03.1
v22.03
v22.02.3
v22.02.2
v22.02.1
v22.02
v21.12.5
v21.12.4
v21.12.3
v21.12.2
v21.12.1
v21.12
v21.11.3
v21.11.2
v21.11.1
v21.11
v21.10.3
v21.10.2
v21.10.1
v21.10
v21.08.6
v21.08.5
v21.08.4
v21.08.3
v21.08.2
v21.08.1
v21.08
v21.05.4
v21.05.3
v21.05.2
v21.05.1
v21.05
v21.04.6
v21.04.5
v21.04.4
v21.04.3
v21.04.2
v21.04.1
v21.04
v0.31.8
v0.31.7
v0.31.6
v0.31.5
v0.31.4
v0.31.3
v0.31.2
v0.31.1
v0.31.0
v0.30.7
v0.30.6
v0.30.5
v0.30.4
v0.30.3
v0.30.2
v0.30.1
v0.30.0
v0.29.3
v0.29.2
v0.29.1
v0.29.0
v0.28.3
v0.28.2
v0.28.1
v0.28.0
v0.27.5
v0.27.4
v0.27.3
v0.27.2
v0.27.1
v0.27
v0.26.4
v0.26.3
v0.26.2
v0.26.1
v0.26.0
v0.25.5
v0.25.4
v0.25.3
v0.25.2
v0.25.1
v0.25.0
v0.24.3
v0.24.2
v0.24.1
v0.24.0
v0.23.2
v0.23.1
v0.23.0
v0.22.0
v0.21.0
v0.20.3
v0.20.2
v0.20.1
v0.20.0
v0.19.0
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.2
v0.12.1
v0.12.0
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
0.7.2
v.0.7.1
v0.7.0
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
Labels
Clear labels
🎨 Design
📖 Docs Update
🐛 Bug
🐛 Bug
:cat2:🐈 Possible duplicate
💿 Database
☕ Open to discussion
💻 Front-End
🐕 Support
🚪 Authentication
🌍 Translations
🔌 API Task
🏭 Back-End
⛲ Upstream
🔨 Feature Request
🛠️ Enhancement
🛠️ Enhancement
🛠️ Enhancement
❤️ Happy feedback
🔒 Security
🔍 Pending Validation
💆 UX
📝 WYSIWYG Editor
🌔 Out of scope
🔩 API Request
:octocat: Admin/Meta
🖌️ View Customization
❓ Question
🚀 Priority
🛡️ Blocked
🚚 Export System
♿ A11y
🔧 Maintenance
> Markdown Editor
pull-request
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/BookStack#5213
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @andrelaszlo on GitHub (Mar 7, 2025).
Describe the Bug
When OIDC is used as the primary authentication method and group sync is configured, some users are not getting the appropriate roles mapped despite being members of the corresponding groups.
Steps to Reproduce
OIDC_GROUPS_CLAIM=groupsin.envExpected Behaviour
At step 7, the user is still a member of G so it should get assigned the role R.
Screenshots or Additional Context
Normally, a claim returned by Azure looks like this:
The list of group ids in
groupscan be used to map groups to BookStack roles. However, when this list grows too large, the corresponding JWT can become too large to fit in the HTTP headers, so Microsoft will instead return a distributed claim for the groups claim if the user has over 200 group memberships (for JWT, 100 for SAML), they refer to this as a groups overage claim.Distributed claims are part of OIDC Core 1.0: [5.6.2. Aggregated and Distributed Claims](https://openid.net/specs/openid-connect-core-1_0.html#AggregatedDistributedClaims.
In this case, the claim will instead look like this:
In the above claim, the
groupskey is missing and is instead represented by_claim_names.groups: src1and_claim_sources.src1: https://graph.windows.net/.../users/.../getMemberObjects. Supporting distributed claims is optional according to the standard, but since this breaks theOIDC_GROUPS_CLAIMfeature in BookStack, I think it should be considered a bug.Browser Details
This bug is not related to the browser being used, but was tested with Microsoft Edge.
Exact BookStack Version
v24.12.1
@andrelaszlo commented on GitHub (Mar 7, 2025):
This might be related to #5306, and now that I did some more digging I see that it's definitely a duplicate of #4885. I totally understand your stance, dealing with identity provider quirks is a never-ending nightmare. I had a quick look and didn't find a good OIDC library for PHP either.
Close?
@andrelaszlo commented on GitHub (Mar 7, 2025):
I might eventually have some time to hack on it, if you'd be interested in a PR.
@ssddanbrown commented on GitHub (Mar 7, 2025):
Thanks for raising @andrelaszlo,
I've recategorized this as a auth feature request, since I don't see it as a bug in existing supported functionality.
To be fair, In those issues I didn't realise that Azure/Entra was at least using (a lesser used) part of the OIDC spec, rather than something custom.
That said, I'm hesitant to grow the scope/features of OIDC further without a decent amount of proven need (ideally provide need across multiple auth systems).
Do you know if Entra provides all groups via the userinfo endpoint?
We've now added support for that so that could be an easier route to support if provided by Entra.
@andrelaszlo commented on GitHub (Mar 7, 2025):
Ok, thanks for the thoughtful review :)
That would have been neat, but unfortunately it doesn't look like it's a supported claim according to the UserInfo endpoint (OIDC) docs:
@ssddanbrown commented on GitHub (Mar 8, 2025):
Darn! Microsoft always has to be awkward.
As a workaround, we expose an event via our logical theme system which allows customization of OIDC data, as shown here:
https://www.bookstackapp.com/blog/bookstack-release-v23-05/#oidc-id-token-logical-theme-event
We provide the access token data as part of that.
It should be possible to use that to perform the further fetch from Entra (assuming to the claim src endpoint) to gain full group data, then supplement the ID token data with fetched groups.
@Tomblarom commented on GitHub (Dec 10, 2025):
For the record, I'm also experiencing this exact issue. Unfortunately, I'm already using this logical theme hack and would have to implement a workaround into my existing logical theme.
Given the existing issues, wouldn't it make sense to implement this directly in Bookstack?
To be honest, when initially setting up Bookstack and dealing with all sorts of different variables (groups, roles, id-connectors, creds, ..), I really wouldn't have thought, that my issue originates from a group limitation, called "Groups overage claim".. My assumption here is, that I am not the only one who didn't realize this and that the actual demand for this implementation is significantly higher.
@ssddanbrown commented on GitHub (Dec 11, 2025):
Here's a logical theme solution, which combines the existing avatar hack, with extra logic to fetch group data over the Graph API where not provided in the ID token:
Note: This does NOT follow the OIDC spec using distributed claims (see next section below).
functions.php code
To use this I had to add 'Microsoft Graph > GroupMember.Read.All' to the app registration's API permissions, then grant admin consent for this permission. It may be possible to have a tighter-scoped permission, but I'm not familiar enough with Microsoft Graph to know for sure.
Entra with Distributed Claims
I tried to originally follow the OIDC spec, and use the Distributed claims via the source URL provided in the token from Entra.
I did not have any luck though going down this road.
On the
_claim_sourcesEntra provides back agraph.windows.netclaim source URL.Using this fails, as the URL requires a version number so you'd have to append:
?api-version=1.6to it manually.Calling that URL gets further, but fails with:
{"odata.error":{"code":"Authentication_MissingOrMalformed","codeForMetrics":"Authentication_MissingOrMalformed","message":{"lang":"en","value":"Access Token missing or malformed."}}}
Even when using the access token from the OIDC flow.
It seems that the graph.windows.net API has different authentication requirements.
Modifying the core original access token flow, to request the access token with a 'resource' of 'https://graph.windows.net/', results in an error:
At this point I gave up on this path, since it was getting deeper and deeper into edits to adapt existing OIDC flow logic.
The 'graph.windows.net' endpoint is for the Azure AD Graph API, which seems to be deprecated and was fully retired as of August 31, 2025 according to Microsoft's docs.
I tried creating a new application registration in Entra, in case this is something specific to older Entra applications, but the result is the same.
Overall this seems wrong and a potentially broken part of Entra's OIDC support, like this corner case has not been updated since the AzureAD Graph API deprecation. Maybe there is something that's causing this at an Entra application level, but I couldn't find any relevant controls/causes. It's also possible I'm just doing something wrong and haven't spotted my mistake, and this should be much simpler.
If someone has some level of real support communication with Microsoft, I'd welcome you to raise this with them and share back the response!
An alternative workaround for Entra
When exploring the above, I did come across this option when configuring the "Groups" claim in the "Token configuration" part of the app registration:
If this does what I understand, this may be a more sensible solution for some which won't require customizations or non-standard functionality. I'm assuming you could assign groups to the application to filter the user groups to just those which you're actually matching up with BookStack roles.
Unfortunately, I could not test this myself since I get this when attempting to assigned groups to my application:
I can however assign the application via editing a group's members, but this does not seem to allow the reverse relation.
If you're on a paid Entra plan, you may have better luck with this.