mirror of
https://github.com/open-webui/open-webui.git
synced 2026-06-03 23:38:13 -05:00
[GH-ISSUE #7102] enh: user groups based on oauth group #85346
Reference in New Issue
Block 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 @tkg61 on GitHub (Nov 20, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/7102
Feature Request
Building on the user groups features in 0.4.0 and the work talked about in discussion #5897:
Could we have the ability to map SSO group membership to groups created in Openwebui at the time of logon.
Describe the solution you'd like
Having this done by the system and a env/ui flag to turn this on and off will ease the administrative burden for larger implementations of openwebui.
This feature would also remove the complication that might arise from multiple frontends and concurrency issues with automation scripts that might come upif these group membership settings don't persist between frontend instances of openwebui (e.g. 5 openwebui containers running all with the same postgres backend)
Describe alternatives you've considered
a script that runs nightly to map users to groups or something that is based on some automation via a ticketing system but it would be tedious and removals would be difficult to manage
@PieterBecking commented on GitHub (Nov 27, 2024):
Would be super helpful!
@a3957273 commented on GitHub (Jan 21, 2025):
This seems to have been completed as part of the linked PR. It isn't currently documented, but does appear to work on the latest release.
@maioranisimone commented on GitHub (Jan 23, 2025):
hello everyone I have read the discussion and I am not sure I understand it well. Is it currently possible to create an oauth group, for example named marketing, and assign a user to that group so that when it login into openwebui it is inside that group without having to enter it via openwebui admin panel? I was only able to create role groups, for example an outh admin group. Also, in case it is possible, does the group on openwebui still have to be created manually first or would it be created automatically for the first user with a new group?
@tkg61 commented on GitHub (Jan 24, 2025):
You have to create the group via the api or web ui but if the name matches the oauth group, then users will be auto added
Edit: You wouldn’t want auto create groups cause some organizations have users with over 100 groups and it would just get messy
@maioranisimone commented on GitHub (Jan 24, 2025):
I create group named "marketing" in my keycloak and assign an user to it. Then i login in owui with this account oidc but he doesn't add automatically to the group
@tkg61 commented on GitHub (Jan 24, 2025):
Did you enable the environment variable for this? The group name matching is case sensitive as well I believe
ENABLE_OAUTH_GROUP_MANAGEMENT=true
@maioranisimone commented on GitHub (Feb 3, 2025):
Yes, I did. I'm using environment variables for OAuth management. For role management, OpenWebUI correctly reads the value from the ID token; however, for group management it does not. I performed a token introspection and confirmed that the value is in the correct position, but when I log in to OWUI, the user is not automatically assigned to the group. I'm using Keycloak.
@wincentek commented on GitHub (Feb 11, 2025):
I can't get this to work either using OAuth.
ENABLE_OAUTH_SIGNUP=True
ENABLE_OAUTH_GROUP_MANAGEMENT=True
(and also OAUTH_MERGE_ACCOUNTS_BY_EMAIL=True)
User(s) can login. Default user role ('user') is applied, but I can't make any automatic Oath groups assignments. I also tried creating groups manually using the same name, but no go.
Do any other environment variables need to be set for this to work?
Thanks :)
@moellert commented on GitHub (Feb 11, 2025):
I had to change the client config in keycloak and make the group claim a default instead of being optional.
Maybe this helps others.
Also this is indeed no group import, just a mapping for existing groups.
@tarmst commented on GitHub (Feb 11, 2025):
I added some additional debug logging for group management here in case it helps: https://github.com/open-webui/open-webui/pull/9620
@thiDucTran commented on GitHub (Feb 13, 2025):
EDIT: please ignore my comment...TLDR: oauth group management would work with both group's names and group's object IDs
Hi, in our
Dex, we specify for group IDs instead of group names, using the configuration optiongroupNameFormat: id(link) . Would group IDs work whenever this is officially rolled out?From below, can confirm that with
ENABLE_OAUTH_GROUP_MANAGEMENT=trueand if the same groupnameexists in open-webui...then said oauth user will be automatically added to the matched oauth group namesnevermind... same flow would also work when we switch to group IDs
@sir3mat commented on GitHub (Feb 19, 2025):
Roles are handled correctly for this scenario thanks to this code
3f3a5bb0ab/backend/open_webui/utils/oauth.py (L102)But groups are loaded like this
3f3a5bb0ab/backend/open_webui/utils/oauth.py (L143)Due to this, the OAUTH_GROUPS_CLAIM can only be "groups"
if jwt is like this (with nestes structure for OAUTH_GROUPS_CLAIM) then groups are not loaded correclty. For roles it works fine.
@tarmst commented on GitHub (Feb 19, 2025):
@sir3mat You're right -- I'll get started on a PR.
@brandonrich commented on GitHub (Apr 4, 2025):
Very excited about this and have been testing it out. Two things:
The next log statement, "Removing user from group..." never occurs. This is because when I remove the last group in my IdP, the "groups" claim in the JWT is fully removed. So the first part of the if statement here fails because
user_oauth_groupsis an empty set, as shown above in the log output.(utils/oauth.py)
@rgaricano commented on GitHub (Apr 4, 2025):
feat: Allow some way of manual group assignments when using OAUTH_GROUP_MANAGEMENT https://github.com/open-webui/open-webui/issues/12392#issuecomment-2776417604
@tkg61 commented on GitHub (Apr 4, 2025):
I know one of the main issues with OWUI creating groups is that some users in enterprise environments will have over 100 groups per user and unless it is filtered before hand (not as easy with straight LDAP) then you’d have a lot of clutter.
One idea could be to look for a prefix that is configured in OWUI and any group with said prefix would get created but that also has its limitations
Creating the groups via api is possible now as well to help onboard :)
@Ithanil commented on GitHub (Apr 4, 2025):
I would advocate for a whitelist of groups to be managed by this feature (and these should then also be created automatically): https://github.com/open-webui/open-webui/issues/12392
It could just be another env variable. Because in some cases such a whitelist might become lengthy, one could also think about supporting regex.
@taylorwilsdon commented on GitHub (Apr 16, 2025):
I will have a PR shortly that implements just in time creation of groups if no matching object exists in OWUI and expose as a settings toggle 👍
@taylorwilsdon commented on GitHub (Apr 18, 2025):
https://github.com/open-webui/open-webui/pull/13039 < PR for Just-in-time group creation
@andrefecto commented on GitHub (Apr 21, 2025):
Hi, I was looking at the code for this and while there is an ENV variable for ENABLE_OAUTH_GROUP_CREATION I do not see that anywhere in the codebase. I also looked in oauth.py and I don't see it checked when running update_user_groups. This could cause unintended behavior.
@taylorwilsdon commented on GitHub (Apr 21, 2025):
@andrefecto this is brand new functionality introduced in the PR above and currently only active if you build the dev branch 👍
The docs were merged yesterday in preparation for the group creation feature release
@JARZcorp commented on GitHub (Apr 29, 2025):
Great progress! Any estimates when the group creation feature will be released to main?
@robbiekouwenberg commented on GitHub (May 2, 2025):
Hi, I was testing the group assignment based on the user groups from a JWT token and was rather surprised about a few things:
Admin's are excluded, we were wondering why this design choice as admin is a role and not a group. if this is about admins being able to join/leave groups being overwritten why not add a manual groups list and keep the group assignment the same for all users. this would be much easier to maintain and also test for functional owner staff.
Enabling the environment variable ENABLE_OAUTH_GROUP_MANAGEMENT on a live environment fails because of Persistent config not picking up the variable, you need to manually add
"oauth": {"enable_group_mapping": "true" }On Azure Entra you are limited by claims mapping that can only send the group id as part of the groups claims. this means you need to set the name of the group as a guid. this is easily solved by showing both the owui group id and description on the overview page so you know what to look for.
@ThisIsNotTheUserYouAreLookingFor commented on GitHub (Aug 18, 2025):
Hi, is there any progress on this issue? I just upgraded to a release from a few days ago, but only my role mapping works. no group mapping.
@taylorwilsdon commented on GitHub (Aug 18, 2025):
There's no issue @ThisIsNotTheUserYouAreLookingFor - it's been live for ages, I use it heavily. If you're not seeing group mapping working, please share your active environment variables, any logs you have and symptoms.
@heguro commented on GitHub (Oct 21, 2025):
https://github.com/open-webui/open-webui/issues/7102#issuecomment-2777308721
I notice this issue appears to still be present in the latest stable release (v0.6.34, using Microsoft Entra ID). Is this considered expected behavior?