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 for validating the changes?
Did not see any oauth-specific tests to extend for this
Instead manual testing in our universities environment hast taken place, testing with and without attatching open-webui to our keycloak based oauth service, with and without enabling role management
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 cleary categorize this pull request, prefix the pull request title, using one of the following:
feat: Introduces a new feature or enhancement to the codebase
Changelog Entry
Description
As described in the Discussion #5897 I added the ability to map roles from your oauth provider to the internal roles "user" and "admin"
While adding this code I figured that moving oauth code to some extra file/class would make sense, so i moved oauth code to utils/oauth
Added
role determination function, covering either legacy role or oauth role mapping if enabled
Changed
moved oauth related code to util class for tightening main script
🔄 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/6238
**Author:** [@Cyb4Black](https://github.com/Cyb4Black)
**Created:** 10/16/2024
**Status:** ✅ Merged
**Merged:** 10/21/2024
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `dev`
---
### 📝 Commits (10+)
- [`9a691c0`](https://github.com/open-webui/open-webui/commit/9a691c038731a00aa61eca9e33f966fd63621fcd) Add oauth role mapping
- [`dc92178`](https://github.com/open-webui/open-webui/commit/dc921786418736d97cabe13625b1bd992063280f) Fix missing key mapping
- [`c9d948f`](https://github.com/open-webui/open-webui/commit/c9d948f2847820a3df460bca5d0f22f5e0cb5598) Remove copy pasta error of calling value on bool
- [`0a7373d`](https://github.com/open-webui/open-webui/commit/0a7373dae18fdc80d354bdb9ce8409cd580de214) add pending as role fallback
- [`5b2e1ca`](https://github.com/open-webui/open-webui/commit/5b2e1ca7cdbeba0070182fca1155f9b07c4c91fe) add more logging
- [`8e4776a`](https://github.com/open-webui/open-webui/commit/8e4776ada16bb94ecf3381fe7ef2653426a25453) add handling nested claims...
- [`79b9c8a`](https://github.com/open-webui/open-webui/commit/79b9c8a677796c11c7f44f40b5be7500920c53b3) handling no claim received when nested expected
- [`6ddd8c7`](https://github.com/open-webui/open-webui/commit/6ddd8c72410baa72203f9012e238cda7cd0c5d50) fix logic
- [`f751d22`](https://github.com/open-webui/open-webui/commit/f751d22a208b3e2d776ecf06ac0889f62b739f68) Refinement
- [`edc15d0`](https://github.com/open-webui/open-webui/commit/edc15d0d7ce0a56f1b8fc601cd23cbabb9ad7e34) rewrite oauth role management logic to allow any custom roles to be used for oauth role to open webui role mapping
### 📊 Changes
**7 files changed** (+356 additions, -223 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/apps/ollama/main.py` (+1 -1)
📝 `backend/open_webui/apps/retrieval/vector/dbs/chroma.py` (+4 -6)
📝 `backend/open_webui/apps/retrieval/vector/dbs/qdrant.py` (+24 -21)
📝 `backend/open_webui/apps/webui/main.py` (+9 -0)
📝 `backend/open_webui/config.py` (+28 -1)
📝 `backend/open_webui/main.py` (+34 -194)
➕ `backend/open_webui/utils/oauth.py` (+256 -0)
</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.
- [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
- [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- ~~**Testing:** Have you written and run sufficient tests for validating the changes?~~
- Did not see any oauth-specific tests to extend for this
- Instead manual testing in our universities environment hast taken place, testing with and without attatching open-webui to our keycloak based oauth service, with and without enabling role management
- [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 cleary categorize this pull request, prefix the pull request title, using one of the following:
- **feat**: Introduces a new feature or enhancement to the codebase
# Changelog Entry
### Description
- As described in the Discussion #5897 I added the ability to map roles from your oauth provider to the internal roles "user" and "admin"
- While adding this code I figured that moving oauth code to some extra file/class would make sense, so i moved oauth code to utils/oauth
### Added
- role determination function, covering either legacy role or oauth role mapping if enabled
### Changed
- moved oauth related code to util class for tightening main script
---
### Additional Information
- [docs PR is here](https://github.com/open-webui/docs/pull/246)
### Screenshots or Videos
-
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/6238
Author: @Cyb4Black
Created: 10/16/2024
Status: ✅ Merged
Merged: 10/21/2024
Merged by: @tjbck
Base:
dev← Head:dev📝 Commits (10+)
9a691c0Add oauth role mappingdc92178Fix missing key mappingc9d948fRemove copy pasta error of calling value on bool0a7373dadd pending as role fallback5b2e1caadd more logging8e4776aadd handling nested claims...79b9c8ahandling no claim received when nested expected6ddd8c7fix logicf751d22Refinementedc15d0rewrite oauth role management logic to allow any custom roles to be used for oauth role to open webui role mapping📊 Changes
7 files changed (+356 additions, -223 deletions)
View changed files
📝
backend/open_webui/apps/ollama/main.py(+1 -1)📝
backend/open_webui/apps/retrieval/vector/dbs/chroma.py(+4 -6)📝
backend/open_webui/apps/retrieval/vector/dbs/qdrant.py(+24 -21)📝
backend/open_webui/apps/webui/main.py(+9 -0)📝
backend/open_webui/config.py(+28 -1)📝
backend/open_webui/main.py(+34 -194)➕
backend/open_webui/utils/oauth.py(+256 -0)📄 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:
devbranch.Testing: Have you written and run sufficient tests for validating the changes?Changelog Entry
Description
Added
Changed
Additional Information
Screenshots or Videos
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.