[PR #13644] [CLOSED] wip: roles and permissions #46305

Closed
opened 2026-04-29 21:03:35 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/13644
Author: @cableman
Created: 5/7/2025
Status: Closed

Base: devHead: feature/roles-endpoint


📝 Commits (10+)

  • d8c3f3b Added roles model
  • 2222fae Added migration for roles table
  • 4193720 Added default roles to database
  • d75be6b Added roles routes
  • a38cc2c Added support for adding new roles
  • 6c754a3 Added support for deleting role
  • 488bc03 Ensured dynamic role assignment is used in oauth
  • 5e8925d Added roles apis to frontend
  • d93cb88 Added support for dynamic roles in frontend
  • 8318cbf Added support for dynamic roles in user add

📊 Changes

27 files changed (+2584 additions, -518 deletions)

View changed files

📝 backend/open_webui/config.py (+39 -5)
📝 backend/open_webui/constants.py (+16 -0)
📝 backend/open_webui/main.py (+9 -1)
backend/open_webui/migrations/versions/04c6df61a317_added_permissions_to_database.py (+55 -0)
backend/open_webui/migrations/versions/262aff902ca3_added_roles_tabel.py (+49 -0)
backend/open_webui/models/permissions.py (+481 -0)
backend/open_webui/models/roles.py (+151 -0)
📝 backend/open_webui/routers/auths.py (+5 -4)
backend/open_webui/routers/permissions.py (+49 -0)
backend/open_webui/routers/roles.py (+198 -0)
📝 backend/open_webui/routers/users.py (+44 -22)
📝 backend/open_webui/utils/oauth.py (+24 -2)
src/lib/apis/permissions/index.ts (+67 -0)
src/lib/apis/roles/index.ts (+214 -0)
📝 src/lib/components/admin/Users.svelte (+46 -0)
📝 src/lib/components/admin/Users/Groups.svelte (+1 -35)
📝 src/lib/components/admin/Users/Groups/EditGroupModal.svelte (+11 -30)
src/lib/components/admin/Users/Groups/Permissions.svelte (+0 -393)
src/lib/components/admin/Users/PermissionList.svelte (+231 -0)
src/lib/components/admin/Users/Permissions/AddPermissionModal.svelte (+157 -0)

...and 7 more files

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests to validate the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

This pull request moved permission and roles into the database, but at the same time do not change the existing API end-point. The reason for moving roles and permissions into the database is to have different default permission for different roles and have the possibility to extend with new permission for "functions/tools"
in custom local code.

Added

  • Roles and permission database tables.
  • New API end-points: /roles and /permissions
  • Support for using OIDC role claims (not limited to the "default" 3 roles)
  • UI for adding new roles and permission
  • UI for setting default permission based on role

Changed

  • Moved all permissions into database (also the default permissions defined in the UI/front end)
  • Added new permission component (that used the database)
  • The existing user permission/default permission end-points return all permissions given.

Removed

  • The "hard-coded" permissions defaults in the front end

Additional Information

Some of the data-structure for permission and roles are not optimal (e.g. the existing permission end-point do not contain labels). We have chosen to do it this way to ensure the existing APIs and data returned is not changed for existing sites out there.

Discussion: https://github.com/open-webui/open-webui/discussions/13200

Screenshots or Videos

Screenshot from 2025-05-07 15-04-15
Screenshot from 2025-05-07 15-04-40
Screenshot from 2025-05-07 15-04-53
Screenshot from 2025-05-07 15-05-05

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/13644 **Author:** [@cableman](https://github.com/cableman) **Created:** 5/7/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feature/roles-endpoint` --- ### 📝 Commits (10+) - [`d8c3f3b`](https://github.com/open-webui/open-webui/commit/d8c3f3bd6aab4e8b70b127935588bf5b31f0d094) Added roles model - [`2222fae`](https://github.com/open-webui/open-webui/commit/2222fae1671a3c8df67b176cf164aa69359787e6) Added migration for roles table - [`4193720`](https://github.com/open-webui/open-webui/commit/4193720d6ebd434a00e81c05949fffdd884c312c) Added default roles to database - [`d75be6b`](https://github.com/open-webui/open-webui/commit/d75be6b46f3c94449e9bb96a5e09234483cf5211) Added roles routes - [`a38cc2c`](https://github.com/open-webui/open-webui/commit/a38cc2cef9313d49fda770c300726507242d04e4) Added support for adding new roles - [`6c754a3`](https://github.com/open-webui/open-webui/commit/6c754a37004a6e11d64c31cc0b0e259dc927fa52) Added support for deleting role - [`488bc03`](https://github.com/open-webui/open-webui/commit/488bc033c6eb959f9759d8ff2010cddffd321a54) Ensured dynamic role assignment is used in oauth - [`5e8925d`](https://github.com/open-webui/open-webui/commit/5e8925db1b183b994a6706130e6de6034ab35dff) Added roles apis to frontend - [`d93cb88`](https://github.com/open-webui/open-webui/commit/d93cb8833fd142844054f7f253e6d4790bdf1f39) Added support for dynamic roles in frontend - [`8318cbf`](https://github.com/open-webui/open-webui/commit/8318cbf31b73d0283ed3a8e2ea78e7b3bb766650) Added support for dynamic roles in user add ### 📊 Changes **27 files changed** (+2584 additions, -518 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/config.py` (+39 -5) 📝 `backend/open_webui/constants.py` (+16 -0) 📝 `backend/open_webui/main.py` (+9 -1) ➕ `backend/open_webui/migrations/versions/04c6df61a317_added_permissions_to_database.py` (+55 -0) ➕ `backend/open_webui/migrations/versions/262aff902ca3_added_roles_tabel.py` (+49 -0) ➕ `backend/open_webui/models/permissions.py` (+481 -0) ➕ `backend/open_webui/models/roles.py` (+151 -0) 📝 `backend/open_webui/routers/auths.py` (+5 -4) ➕ `backend/open_webui/routers/permissions.py` (+49 -0) ➕ `backend/open_webui/routers/roles.py` (+198 -0) 📝 `backend/open_webui/routers/users.py` (+44 -22) 📝 `backend/open_webui/utils/oauth.py` (+24 -2) ➕ `src/lib/apis/permissions/index.ts` (+67 -0) ➕ `src/lib/apis/roles/index.ts` (+214 -0) 📝 `src/lib/components/admin/Users.svelte` (+46 -0) 📝 `src/lib/components/admin/Users/Groups.svelte` (+1 -35) 📝 `src/lib/components/admin/Users/Groups/EditGroupModal.svelte` (+11 -30) ➖ `src/lib/components/admin/Users/Groups/Permissions.svelte` (+0 -393) ➕ `src/lib/components/admin/Users/PermissionList.svelte` (+231 -0) ➕ `src/lib/components/admin/Users/Permissions/AddPermissionModal.svelte` (+157 -0) _...and 7 more files_ </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [ ] **Testing:** Have you written and run sufficient tests to validate the changes? - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description This pull request moved permission and roles into the database, but at the same time do not change the existing API end-point. The reason for moving roles and permissions into the database is to have different default permission for different roles and have the possibility to extend with new permission for "functions/tools" in custom local code. ### Added - Roles and permission database tables. - New API end-points: /roles and /permissions - Support for using OIDC role claims (not limited to the "default" 3 roles) - UI for adding new roles and permission - UI for setting default permission based on role ### Changed - Moved all permissions into database (also the default permissions defined in the UI/front end) - Added new permission component (that used the database) - The existing user permission/default permission end-points return all permissions given. ### Removed - The "hard-coded" permissions defaults in the front end --- ### Additional Information Some of the data-structure for permission and roles are not optimal (e.g. the existing permission end-point do not contain labels). We have chosen to do it this way to ensure the existing APIs and data returned is __not__ changed for existing sites out there. Discussion: https://github.com/open-webui/open-webui/discussions/13200 ### Screenshots or Videos ![Screenshot from 2025-05-07 15-04-15](https://github.com/user-attachments/assets/fec2f187-8a62-4f41-833a-544ce452fb14) ![Screenshot from 2025-05-07 15-04-40](https://github.com/user-attachments/assets/d2dae140-a215-4141-8db3-68d7ca931fbd) ![Screenshot from 2025-05-07 15-04-53](https://github.com/user-attachments/assets/cf3a87ae-e252-4f32-bb3b-2de318bc8fca) ![Screenshot from 2025-05-07 15-05-05](https://github.com/user-attachments/assets/70fe32ac-ba5f-4443-8f0c-e2c5f803c9c8) ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-29 21:03:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#46305