[PR #13039] [MERGED] feat: Just-in-Time Group Creation for OAuth Groups #9877

Closed
opened 2025-11-11 18:33:53 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/13039
Author: @taylorwilsdon
Created: 4/18/2025
Status: ✅ Merged
Merged: 4/19/2025
Merged by: @tjbck

Base: dev ← Head: jit_oauth_groups


📝 Commits (7)

  • 0a2747b Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev
  • 66bf6d8 Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev
  • 708fcdc Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev
  • 0fc5699 Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev
  • 54c6e64 Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev
  • a67e5f7 Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev
  • 1dbf4d0 Add ENABLE_OAUTH_GROUP_CREATION flag for JIT group creation with OAuth group updates enabled

📊 Changes

1 file changed (+41 additions, -1 deletions)

View changed files

📝 backend/open_webui/utils/oauth.py (+41 -1)

📄 Description

Pull Request Checklist

  • 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.
  • [x ] Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources? (Note: Documentation update might be needed for the new environment variable). - will have a matching PR that updates this!
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • [x ] 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 introduces the capability for Open WebUI to automatically create user groups during OAuth login if they are present in the user's OAuth claims but do not yet exist in the system. This behavior is controlled by a new configuration setting, ENABLE_OAUTH_GROUP_CREATION.

Added

  • New environment variable and PersistentConfig setting ENABLE_OAUTH_GROUP_CREATION to control automatic group creation during OAuth login.
  • Logic within backend/open_webui/utils/oauth.py to check for missing groups based on OAuth claims and create them if ENABLE_OAUTH_GROUP_CREATION is enabled.

Changed

  • Modified backend/open_webui/utils/oauth.py in the update_user_groups function to incorporate the group creation logic.

Deprecated

  • N/A

Removed

  • N/A

Fixed

  • Ensured that group creation uses an existing admin user's ID as the creator, falling back to the logging-in user's ID only if no admin exists. This prevents failures when the logging-in user lacks group creation permissions.

Security

  • N/A

Breaking Changes

  • N/A

Additional Information

  • This feature enhances the existing OAuth group management by allowing seamless integration with identity providers that manage group memberships externally.
  • Documentation should be updated to reflect the new ENABLE_OAUTH_GROUP_CREATION environment variable and its functionality.

Screenshots or Videos

  • N/A

🔄 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/13039 **Author:** [@taylorwilsdon](https://github.com/taylorwilsdon) **Created:** 4/18/2025 **Status:** ✅ Merged **Merged:** 4/19/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `jit_oauth_groups` --- ### 📝 Commits (7) - [`0a2747b`](https://github.com/open-webui/open-webui/commit/0a2747bc6a97f7dd14e2e08c5b5be4c11ab2f66a) Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev - [`66bf6d8`](https://github.com/open-webui/open-webui/commit/66bf6d88bc298e1547f22f8baaf951a7c96b14bc) Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev - [`708fcdc`](https://github.com/open-webui/open-webui/commit/708fcdc6b786e8790d2ec30d72b7d3dc854f26dd) Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev - [`0fc5699`](https://github.com/open-webui/open-webui/commit/0fc56995337089662f4de0ec729725450a20ecc3) Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev - [`54c6e64`](https://github.com/open-webui/open-webui/commit/54c6e64eecedc5b61534285e958de1df0ec9e3cd) Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev - [`a67e5f7`](https://github.com/open-webui/open-webui/commit/a67e5f725f5ebbc13df063dadba14ccfc0dab9f3) Merge branch 'dev' of github.com:taylorwilsdon/open-webui into dev - [`1dbf4d0`](https://github.com/open-webui/open-webui/commit/1dbf4d04615ae463b6524bb32b770c46a2fa2ef0) Add ENABLE_OAUTH_GROUP_CREATION flag for JIT group creation with OAuth group updates enabled ### 📊 Changes **1 file changed** (+41 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/oauth.py` (+41 -1) </details> ### 📄 Description # Pull Request Checklist - [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? (Note: Documentation update might be needed for the new environment variable). - will have a matching PR that updates this! - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x ] **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 introduces the capability for Open WebUI to automatically create user groups during OAuth login if they are present in the user's OAuth claims but do not yet exist in the system. This behavior is controlled by a new configuration setting, `ENABLE_OAUTH_GROUP_CREATION`. ### Added - New environment variable and `PersistentConfig` setting `ENABLE_OAUTH_GROUP_CREATION` to control automatic group creation during OAuth login. - Logic within `backend/open_webui/utils/oauth.py` to check for missing groups based on OAuth claims and create them if `ENABLE_OAUTH_GROUP_CREATION` is enabled. ### Changed - Modified `backend/open_webui/utils/oauth.py` in the `update_user_groups` function to incorporate the group creation logic. ### Deprecated - N/A ### Removed - N/A ### Fixed - Ensured that group creation uses an existing admin user's ID as the creator, falling back to the logging-in user's ID only if no admin exists. This prevents failures when the logging-in user lacks group creation permissions. ### Security - N/A ### Breaking Changes - N/A --- ### Additional Information - This feature enhances the existing OAuth group management by allowing seamless integration with identity providers that manage group memberships externally. - Documentation should be updated to reflect the new `ENABLE_OAUTH_GROUP_CREATION` environment variable and its functionality. ### Screenshots or Videos - N/A --- <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 2025-11-11 18:33:53 -06: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#9877