Skip to content

Commit 7824cde

Browse files
committed
4856: Ensured that role names from OIDC is kept
1 parent 8d7d79d commit 7824cde

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

backend/open_webui/utils/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def get_current_user_by_api_key(api_key: str):
350350

351351

352352
def get_verified_user(user=Depends(get_current_user)):
353-
if user.role not in {"user", "admin"}:
353+
if user.role not in {"user", "admin", "builder", "local-admin"}:
354354
raise HTTPException(
355355
status_code=status.HTTP_401_UNAUTHORIZED,
356356
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,

backend/open_webui/utils/oauth.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,12 @@ def get_user_role(self, user, user_data):
877877
for allowed_role in oauth_allowed_roles:
878878
# If the user has any of the allowed roles, assign the role "user"
879879
if allowed_role in oauth_roles:
880-
log.debug("Assigned user the user role")
881-
role = "user"
880+
log.debug(f"Using first role from OAuth: {oauth_roles[0]}")
881+
first_role = oauth_roles[0]
882+
if first_role == "end-user":
883+
role = "user"
884+
else:
885+
role = first_role
882886
break
883887
for admin_role in oauth_admin_roles:
884888
# If the user has any of the admin roles, assign the role "admin"

src/lib/components/admin/Users/UserList/EditUserModal.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@
139139
disabled={_user.id == sessionUser.id}
140140
required
141141
>
142-
<option value="admin">{$i18n.t('Admin')}</option>
143-
<option value="user">{$i18n.t('User')}</option>
144-
<option value="pending">{$i18n.t('Pending')}</option>
142+
<option value="admin">{$i18n.t('Admin')}</option>
143+
<option value="user">{$i18n.t('User')}</option>
144+
<option value="local-admin">{$i18n.t('Local admin')}</option>
145+
<option value="builder">{$i18n.t('Builder')}</option>
146+
<option value="pending">{$i18n.t('Pending')}</option>
145147
</select>
146148
</div>
147149
</div>

src/routes/(app)/+layout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
<div
326326
class=" text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-900 h-screen max-h-[100dvh] overflow-auto flex flex-row justify-end"
327327
>
328-
{#if !['user', 'admin'].includes($user?.role)}
328+
{#if ['pending'].includes($user?.role)}
329329
<AccountPending />
330330
{:else}
331331
{#if localDBChats.length > 0}

0 commit comments

Comments
 (0)