Skip to content

feat: add workspace permission control for enterprise edition#30487

Closed
GareArc wants to merge 0 commit into
mainfrom
feat/workspace-permission-ee
Closed

feat: add workspace permission control for enterprise edition#30487
GareArc wants to merge 0 commit into
mainfrom
feat/workspace-permission-ee

Conversation

@GareArc

@GareArc GareArc commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Copilot AI review requested due to automatic review settings January 4, 2026 02:55
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 💪 enhancement New feature or request labels Jan 4, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @GareArc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a robust workspace permission control system tailored for the enterprise edition. It introduces a new module to centralize permission checks for critical actions like inviting members and transferring workspace ownership, ensuring that both billing plan limitations and administrator-defined enterprise policies are enforced. Additionally, it exposes an API for enterprise users to query these permissions and includes comprehensive unit tests to validate the new logic.

Highlights

  • Centralized Workspace Permission Checks: Introduced libs/workspace_permission.py to consolidate permission logic for member invitations and owner transfers, checking both billing plan and enterprise policy.
  • Enterprise-Specific Permission API: Added a new API endpoint /workspaces/current/permission to retrieve detailed workspace permission settings for enterprise users, restricted to the enterprise edition.
  • Enhanced Invitation Security: Integrated workspace member invitation permission checks into the invitation activation flow, the member invitation API, and the account service to enforce enterprise policies.
  • Refactored Owner Transfer Logic: Updated the is_allow_transfer_owner decorator to leverage the new centralized permission checking mechanism, ensuring consistent policy enforcement.
  • New Data Model and Service: Defined a WorkspacePermission Pydantic model and a corresponding service method within EnterpriseService to interact with the enterprise backend for permission data.
  • Comprehensive Unit Tests: Added dedicated unit tests for the new workspace permission helper functions, covering various scenarios including community vs. enterprise editions, blocking/allowing policies, and error handling.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds workspace permission controls for member invitations and owner transfers, which is a great enhancement for the enterprise edition. The implementation introduces new endpoints, services, and helper functions to manage these permissions. My review has identified a potential bug in the account activation flow where an incorrect workspace ID might be used, an incorrect test case that could lead to a false sense of security, and a misleading docstring in the new permission helper module. I've also pointed out a minor style improvement for code consistency. Addressing these points will improve the robustness and maintainability of the new feature.

Comment thread api/controllers/console/auth/activate.py Outdated
Comment thread api/tests/unit_tests/libs/test_workspace_permission.py Outdated
Comment thread api/libs/workspace_permission.py Outdated
Comment thread api/services/enterprise/enterprise_service.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds workspace permission control functionality for the enterprise edition, allowing administrators to control workspace features like member invitations and ownership transfers through workspace-specific policies. The implementation includes both billing plan level and enterprise policy level checks.

  • Adds WorkspacePermission model and API integration with enterprise service
  • Implements permission helper functions that check both billing/plan and workspace policy levels
  • Integrates permission checks into member invitation and ownership transfer workflows

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
api/libs/workspace_permission.py New helper module with permission check functions for member invites and owner transfers
api/services/enterprise/enterprise_service.py Adds WorkspacePermission model and nested service class to fetch workspace permissions from enterprise API
api/services/account_service.py Integrates workspace permission check into the member invitation flow
api/controllers/console/workspace/members.py Adds permission check before processing member invitation requests
api/controllers/console/auth/activate.py Adds secondary permission check during invitation token redemption
api/controllers/console/wraps.py Updates ownership transfer decorator to use new permission check helper
api/controllers/console/workspace/workspace.py Adds new API endpoint to retrieve workspace permissions for the current workspace
api/tests/unit_tests/libs/test_workspace_permission.py Comprehensive unit tests covering community/enterprise editions and fail-open behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/libs/workspace_permission.py Outdated
Comment thread api/libs/workspace_permission.py Outdated
Comment thread api/controllers/console/auth/activate.py Outdated
Comment thread api/services/enterprise/enterprise_service.py Outdated
Comment thread api/services/enterprise/enterprise_service.py Outdated
Comment thread api/tests/unit_tests/libs/test_workspace_permission.py Outdated
Comment thread api/libs/workspace_permission.py Outdated
@GareArc
GareArc force-pushed the feat/workspace-permission-ee branch 2 times, most recently from 983d176 to 4a32b10 Compare January 9, 2026 02:12
@GareArc GareArc closed this Jan 15, 2026
@GareArc
GareArc force-pushed the feat/workspace-permission-ee branch from 0fe2335 to b06c7c8 Compare January 15, 2026 23:05
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants