[mirror] feat(permissions): migrate admin endpoints and UI to group-based permission checks#2
[mirror] feat(permissions): migrate admin endpoints and UI to group-based permission checks#2yashwant86 wants to merge 12 commits intomm-base-10174from
Conversation
…ssion checks for document sets and personas
…r actions and enhance agent creation button with permission validation
… handling and permission checks
… and bots management
…ess tokens and enhance UI with permission validation
… to new permission system (onyx-dot-app#10175)
…s when not editable
⚡ Risk Assessment —
|
| Files | Summary |
|---|---|
EE CC Pair Error Handlingbackend/ee/onyx/server/documents/cc_pair.py |
Replaces HTTPException with OnyxError for permission/conflict/internal errors in sync endpoints, using proper error codes (INSUFFICIENT_PERMISSIONS, CONFLICT, INTERNAL_ERROR) instead of raw HTTP status codes. |
Permission System Corebackend/onyx/auth/permissions.py |
Adds READ_USERS and READ_DOCUMENT_SETS permissions; auto-grants permissions to all users in Community Edition; adds _get_current_user() helper for permission dependency injection. |
Admin Endpoint Permission Migrationbackend/onyx/server/documents/cc_pair.pybackend/onyx/server/features/document_set/api.pybackend/ee/onyx/server/user_group/api.pybackend/onyx/server/features/mcp/api.pybackend/ee/onyx/server/oauth/api.pybackend/ee/onyx/server/oauth/confluence_cloud.pybackend/ee/onyx/server/oauth/google_drive.pybackend/ee/onyx/server/oauth/slack.pybackend/ee/onyx/server/query_history/api.pybackend/onyx/server/api_key/api.pybackend/onyx/server/manage/administrative.pybackend/onyx/server/features/tool/api.pybackend/onyx/server/federated/api.pybackend/onyx/server/manage/discord_bot/api.pybackend/onyx/server/manage/slack_bot.pybackend/onyx/server/onyx_api/ingestion.pybackend/ee/onyx/server/token_rate_limits/api.py |
Replaces current_curator_or_admin_user dependency with require_permission(Permission.FULL_ADMIN_PANEL_ACCESS) or specific permission checks on admin endpoints. |
User Role & Permission Refactoringbackend/onyx/auth/users.pybackend/onyx/db/auth.pybackend/onyx/db/models.pybackend/onyx/auth/schemas.pybackend/onyx/auth/api_key.py |
Refactors user role handling to support nullable role field; updates role assignment logic for API keys and user creation; removes legacy role-based permission checks. |
Database & Permission Queriesbackend/onyx/db/persona.pybackend/onyx/db/document_set.pybackend/onyx/db/connector_credential_pair.pybackend/onyx/db/credentials.pybackend/onyx/db/feedback.pybackend/onyx/db/users.pybackend/onyx/db/api_key.pybackend/onyx/db/notification.pybackend/onyx/db/user_preferences.pybackend/ee/onyx/db/user_group.pybackend/ee/onyx/db/token_limit.pybackend/ee/onyx/db/analytics.pybackend/ee/onyx/db/license.py |
Replaces role-based permission checks with group-based Permission system; removes legacy role-specific logic (CURATOR, GLOBAL_CURATOR, LIMITED, SLACK_USER, EXT_PERM_USER); simplifies queries to use has_permission() and get_effective_permissions(). |
User Management APIbackend/onyx/server/manage/users.py |
Removes set-user-role and get-user-role endpoints; updates user snapshot serialization to include is_admin flag; refactors user counts by role to use new permission model. |
Error Handling & Codesbackend/onyx/error_handling/error_codes.py |
Adds BAD_REQUEST and DOCUMENT_SET_NOT_FOUND error codes for consistent error handling across endpoints. |
Database Migrationbackend/alembic/versions/c8e316473aaa_make_user_role_nullable.py |
Adds migration to make user.role column nullable, supporting transition to group-based permission model. |
Test Infrastructure & Fixturesbackend/tests/integration/tests/permissions/conftest.pybackend/tests/integration/common_utils/managers/user.pybackend/tests/integration/common_utils/managers/user_group.pybackend/tests/integration/common_utils/managers/api_key.pybackend/tests/integration/conftest.py |
Updates test fixtures and managers to use group-based permission model; adds helper methods for permission-based user creation and group assignment. |
Permission-Based Integration Testsbackend/tests/integration/tests/permissions/_access_matrix.py, test_add_agents.py, test_admin_access.py, test_create_user_api_keys.py, test_manage_actions.py, test_manage_agents.py, test_manage_bots.py, test_manage_connectors.py, test_manage_document_sets.py, test_manage_llms.py, test_manage_service_account_api_keys.py, test_manage_user_groups.py, test_read_query_history.py, test_file_connector_permissions.py |
Adds comprehensive permission-gated endpoint tests covering ADD_AGENTS, CREATE_USER_API_KEYS, MANAGE_* operations; replaces legacy role-based tests with permission matrix validation. |
Deleted Legacy Permission Testsbackend/tests/integration/tests/permissions/test_cc_pair_permissions.py, test_connector_permissions.py, test_doc_set_permissions.py, test_credential_permissions.py, test_persona_permissions.py, test_whole_curator_flow.py, test_user_role_permissions.py |
Removes obsolete role-based permission tests; replaced by new permission-gated endpoint tests. |
Test Utilities & Helpersbackend/tests/integration/tests/api_key/test_api_key.pybackend/tests/integration/tests/connector/test_connector_deletion.pybackend/tests/integration/tests/document_set/test_syncing.pybackend/tests/integration/tests/pat/test_pat_api.pybackend/tests/integration/tests/query_history/test_query_history.pybackend/tests/integration/tests/query_history/utils.pybackend/tests/integration/tests/usergroup/test_usergroup_syncing.pybackend/tests/integration/tests/users/test_slack_user_deactivation.pybackend/tests/integration/tests/users/test_user_pagination.pybackend/tests/integration/tests/users/test_password_signup_upgrade.pybackend/tests/integration/tests/users/test_default_group_assignment.pybackend/tests/integration/tests/auth/test_saml_user_conversion.pybackend/tests/integration/multitenant_tests/discord_bot/test_discord_bot_multitenant.pybackend/tests/integration/multitenant_tests/invitation/test_user_invitation.pybackend/tests/integration/multitenant_tests/tenants/test_tenant_creation.pybackend/tests/integration/multitenant_tests/syncing/test_search_permissions.pybackend/tests/integration/tests/anonymous_user/test_anonymous_user.pybackend/tests/integration/tests/chat/test_chat_session_access.pybackend/tests/integration/tests/scim/test_scim_groups.pybackend/tests/integration/tests/scim/test_scim_users.pybackend/tests/integration/tests/llm_provider/test_llm_provider.pybackend/tests/external_dependency_unit/db/test_user_account_type.pybackend/tests/external_dependency_unit/llm/test_llm_provider_api_base.pybackend/tests/external_dependency_unit/llm/test_llm_provider.pybackend/tests/external_dependency_unit/llm/test_llm_provider_auto_mode.pybackend/tests/external_dependency_unit/llm/test_llm_provider_called.pybackend/tests/external_dependency_unit/connectors/google_drive/test_google_drive_group_sync.pybackend/tests/external_dependency_unit/craft/conftest.pybackend/tests/external_dependency_unit/conftest.pybackend/tests/daily/conftest.pybackend/tests/unit/onyx/auth/test_jwt_provisioning.pybackend/tests/unit/onyx/auth/test_user_registration.pybackend/tests/unit/onyx/auth/test_permissions.pybackend/tests/unit/onyx/server/scim/conftest.pybackend/tests/unit/onyx/server/test_full_user_snapshot.py |
Updates test utilities to use new permission-based access patterns; refactors user creation and API key setup to leverage group-based permissions. |
Frontend Admin Routes & Permissionsweb/src/lib/admin-routes.ts, admin-sidebar-utils.ts |
Updates admin route permission requirements from 'admin' role to specific Permission enum values (manage:llms, manage:connectors, etc.). |
Frontend User & Permission Typesweb/src/lib/types.ts, permissions.ts |
Adds is_admin flag to User type; updates UserRole enum to remove LIMITED/SLACK_USER/EXT_PERM_USER; refactors Permission type to use string literals for permission checks. |
Frontend User Provider & Authweb/src/providers/UserProvider.tsxweb/src/lib/auth/requireAuth.ts |
Updates UserProvider to derive isAdmin from user.role === ADMIN; refactors auth checks to use permission-based access control via groups. |
Frontend Admin Users Managementweb/src/refresh-pages/admin/UsersPage/index.tsxweb/src/refresh-pages/admin/UsersPage/UsersTable.tsxweb/src/refresh-pages/admin/UsersPage/UserFilters.tsxweb/src/refresh-pages/admin/UsersPage/EditUserModal.tsxweb/src/refresh-pages/admin/UsersPage/AccountTypeCell.tsxweb/src/refresh-pages/admin/UsersPage/svc.tsweb/src/hooks/useAdminUsers.tsweb/src/hooks/useUserCounts.ts |
Removes user role editing UI; replaces with account type display; updates user filtering and counts to use new permission model; removes setUserRole API call. |
Frontend Service Accounts & API Keysweb/src/refresh-pages/admin/ServiceAccountsPage/index.tsx, ApiKeyFormModal.tsx, interfaces.ts |
Removes API key role change functionality; updates form to use group-based permissions instead of direct role assignment. |
Frontend Groups Managementweb/src/refresh-pages/admin/GroupsPage/shared.tsx, useGroupMemberCandidates.ts, EditGroupPage.tsx, CreateGroupPage.tsx, GroupPermissionsSection.tsx, interfaces.ts |
Adds permission management UI for groups; updates member candidate selection to include API keys; refactors permission section for bulk permission assignment. |
Frontend Document Sets & Connectorsweb/src/app/admin/documents/sets/DocumentSetCreationForm.tsxweb/src/app/admin/connector/[ccPairId]/page.tsxweb/src/components/admin/connectors/AccessTypeGroupSelector.tsxweb/src/components/IsPublicGroupSelector.tsx |
Updates curator role checks to use permission-based access; refactors group selector logic for permission-aware filtering. |
Frontend Agents & Toolsweb/src/refresh-pages/AgentsNavigationPage.tsxweb/src/refresh-pages/admin/AgentsPage/AgentRowActions.tsxweb/src/refresh-pages/AgentEditorPage.tsxweb/src/sections/cards/AgentCard.tsxweb/src/sections/modals/ShareAgentModal.tsx |
Updates agent creation and editing to use permission-based access checks instead of role-based; refactors curator/admin checks. |
Frontend Settings & PATweb/src/refresh-pages/SettingsPage.tsxweb/src/sections/sidebar/AppSidebar.tsxweb/src/sections/sidebar/CreateConnectorSidebar.tsxweb/src/sections/onboarding/OnboardingFlow.tsxweb/src/sections/modals/llmConfig/shared.tsxweb/src/app/craft/v1/configure/page.tsxweb/src/refresh-pages/AppPage.tsx |
Updates permission checks throughout UI to use hasPermission() helper; refactors curator/admin role checks to permission-based access. |
Frontend Component Utilitiesweb/src/components/ConnectorMultiSelect.tsxweb/src/components/GenericMultiSelect.tsxweb/src/refresh-components/popovers/ActionsPopover/index.tsxweb/src/app/admin/ClientLayout.tsxweb/src/app/admin/ClientLayout.test.tsx |
Adds test IDs for search inputs; updates permission checks in action popovers; adds ClientLayout test for permission-based routing. |
Frontend Deleted Componentsweb/src/components/admin/users/SignedUpUserTable.tsxweb/src/refresh-pages/admin/UsersPage/UserRoleCell.tsxweb/src/components/admin/users/buttons/UserRoleDropdown.tsx |
Removes user role UI components; replaced by account type display and group-based permission management. |
E2E Tests & Utilitiesweb/tests/e2e/admin/permissions/fixtures.tsweb/tests/e2e/admin/permissions/permission_gating.spec.tsweb/tests/e2e/admin/permissions/permission_system.spec.tsweb/tests/e2e/utils/permissions.tsweb/tests/e2e/utils/onyxApiClient.tsweb/tests/e2e/global-setup.tsweb/tests/e2e/onboarding/onboarding_flow.spec.tsweb/tests/e2e/agents/create_and_edit_agent.spec.tsweb/tests/e2e/mcp/mcp_oauth_flow.spec.ts |
Adds comprehensive E2E tests for permission gating; updates API client to use new setUserRole endpoint; adds permission group cleanup utilities. |
Sequence Diagram
sequenceDiagram
participant Client
participant FastAPI
participant PermissionDep as require_permission()
participant UserGroups as User Groups DB
participant Endpoint
Client->>FastAPI: POST /admin/connectors
FastAPI->>PermissionDep: Resolve dependency
PermissionDep->>UserGroups: Fetch user's groups
UserGroups-->>PermissionDep: Return group list
PermissionDep->>PermissionDep: Check if any group has FULL_ADMIN_PANEL_ACCESS
alt User has permission
PermissionDep-->>FastAPI: Return user
FastAPI->>Endpoint: Call endpoint
Endpoint-->>Client: 200 OK + result
else User lacks permission
PermissionDep-->>FastAPI: Raise HTTPException 403
FastAPI-->>Client: 403 Forbidden
end
Dig Deeper With Commands
/review <file-path> <function-optional>/chat <file-path> "<question>"/roast <file-path>
Runs only when explicitly triggered.
Mirror of upstream onyx-dot-app#10174 for benchmark. Do not merge.
Summary by MergeMonkey