Skip to content

Commit a308be2

Browse files
committed
4856: Ensured that role names from OIDC is kept
1 parent a28ca30 commit a308be2

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
@@ -335,7 +335,7 @@ def get_current_user_by_api_key(api_key: str):
335335

336336

337337
def get_verified_user(user=Depends(get_current_user)):
338-
if user.role not in {"user", "admin"}:
338+
if user.role not in {"user", "admin", "builder", "local-admin"}:
339339
raise HTTPException(
340340
status_code=status.HTTP_401_UNAUTHORIZED,
341341
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
@@ -181,8 +181,12 @@ def get_user_role(self, user, user_data):
181181
for allowed_role in oauth_allowed_roles:
182182
# If the user has any of the allowed roles, assign the role "user"
183183
if allowed_role in oauth_roles:
184-
log.debug("Assigned user the user role")
185-
role = "user"
184+
log.debug(f"Using first role from OAuth: {oauth_roles[0]}")
185+
first_role = oauth_roles[0]
186+
if first_role == "end-user":
187+
role = "user"
188+
else:
189+
role = first_role
186190
break
187191
for admin_role in oauth_admin_roles:
188192
# 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)