Repository navigation
Conversation
…workspace roles at auditor user_level() gave an extension user the highest role they held in any workspace. Any signed-in user can create a workspace and become its admin, so every user could reach admin-only extensions: the menu entry, /x/<slug>/ and /ext/authz?role=admin. Extensions are instance-wide, so the admin level now comes from is_staff and the superuser level from is_superuser. Workspace roles still count, up to auditor. The existing extension tests gave their admin a workspace admin row; that user is now a staff user with a viewer row for the active workspace. test_extensions_self_admin.py covers the self-created workspace via the service, the API and self-registration.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #83, from the comment on #77 (direction 1 there), limited to the extensions.
What changes
user_level()ininfra/extensions.pygave a user the highest role they held in any workspace. Any signed-in user can create a workspace and become its admin (create_workspaceinaccounts/services.py), so any user could reach admin-only extensions: the menu entry,/x/<slug>/and/ext/authz?role=admin.Now
superusercomes fromis_superuserandadminfromis_staff. Workspace roles still count, but only up toauditor. The Roles section ofdocs/extensions.mddescribes the new rule.chat/config.pyis not touched.Reproduction
infra/tests/test_extensions_self_admin.pyis the test from the #77 comment, unchanged. A user creates a workspace through the service, through the API, or by self-registering and then using the API. After that, the user must not see the admin-only menu entry, open its embed page or pass/ext/authz?role=admin. All three tests fail on main 254d63d and pass on this branch.Existing tests that changed (
infra/tests/test_extensions.py)setUp(lines 88–90):self.adminwas a workspace admin. It is now a staff user with aviewerrow, which only gives it an active workspace. The tests that use it check the same things as before.test_authz(line 188):X-Studio-Rolefor that user is nowuser, notadmin. The header still comes fromchat.config.identity(), which maps only superusers and workspace admins to the Open WebUI admin role, and this user has no workspace admin row.test_workspace_roles_count_up_to_auditor(lines 168–182): a workspace admin withoutis_staffsees anauditorentry but not the admin one, hasrole: "auditor"inwindow.Studio, and gets 200 from/ext/authz?role=auditorand 403 from?role=admin.Checked
uv run pytest -m "not embedded_hatchet" -n 4: 1681 passed, 2 skipped and 2 failed on this branch; 1677 passed, 2 skipped and the same 2 failed on main 254d63d. The 4 extra passes are the new tests. Both failures also fail on their own, on main as on the branch, and come from this machine:test_live_clef_flash_answers_and_rendersruns because a local Ollama serves clef-flash, andtest_time_wait_leftovers_do_not_block_but_a_live_listener_doesgetsConnectionResetErroron macOS.infra/extensions.py, all 8 of these fail: the three reproduction tests, the four tests that useself.adminand the new one.uv run ruff check .is clean.Design questions
admincome fromis_staff, or would you rather have a separate instance flag? Today only the bootstrap admin getsis_staff, and that user is also a superuser (accounts/services.py:68). Anyone else has to be made staff in Django admin.viewerandauditorthrough a workspace they created themselves. Is that acceptable for extensions, which apply to the whole instance?/ext/authzstill copiesX-Studio-Rolefromchat.config.identity(), which follows the rule Workspace admin is treated as a global privilege (Open WebUI admin role, ADMINS connection sharing) #77 is about. On this branch, a user who creates a workspace and calls/ext/authz?role=viewergets 200 withX-Studio-Role: admin, and a staff user with no workspace admin row getsuser. This PR leaves the header to whatever Workspace admin is treated as a global privilege (Open WebUI admin role, ADMINS connection sharing) #77 settles.AI disclosure: implemented with Claude Code.