Skip to content

Commit e25963b

Browse files
committed
4856: Ensured that role names from OIDC is kept
1 parent 918f507 commit e25963b

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

backend/open_webui/utils/auth.py

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

348348

349349
def get_verified_user(user=Depends(get_current_user)):
350-
if user.role not in {"user", "admin"}:
350+
if user.role not in {"user", "admin", "builder", "local-admin"}:
351351
raise HTTPException(
352352
status_code=status.HTTP_401_UNAUTHORIZED,
353353
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
@@ -364,8 +364,12 @@ def get_user_role(self, user, user_data):
364364
for allowed_role in oauth_allowed_roles:
365365
# If the user has any of the allowed roles, assign the role "user"
366366
if allowed_role in oauth_roles:
367-
log.debug("Assigned user the user role")
368-
role = "user"
367+
log.debug(f"Using first role from OAuth: {oauth_roles[0]}")
368+
first_role = oauth_roles[0]
369+
if first_role == "end-user":
370+
role = "user"
371+
else:
372+
role = first_role
369373
break
370374
for admin_role in oauth_admin_roles:
371375
# If the user has any of the admin roles, assign the role "admin"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
>
117117
<option value="admin">{$i18n.t('Admin')}</option>
118118
<option value="user">{$i18n.t('User')}</option>
119+
<option value="local-admin">{$i18n.t('Local admin')}</option>
120+
<option value="builder">{$i18n.t('Builder')}</option>
119121
<option value="pending">{$i18n.t('Pending')}</option>
120122
</select>
121123
</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
<div
292292
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"
293293
>
294-
{#if !['user', 'admin'].includes($user?.role)}
294+
{#if ['pending'].includes($user?.role)}
295295
<AccountPending />
296296
{:else}
297297
{#if localDBChats.length > 0}

0 commit comments

Comments
 (0)