[mirror] feat(permissions): wire LLM admin + user group + sidebar access onto new permission system#1
Open
yashwant86 wants to merge 6 commits intomm-base-10173from
Open
[mirror] feat(permissions): wire LLM admin + user group + sidebar access onto new permission system#1yashwant86 wants to merge 6 commits intomm-base-10173from
yashwant86 wants to merge 6 commits intomm-base-10173from
Conversation
…checks to use MANAGE_LLMS
…ions and admin checks
…oup access checks
…mission and add tests for permission functions
⚡ Risk Assessment —
|
| Files | Summary |
|---|---|
Permission System Corebackend/onyx/auth/permissions.pybackend/onyx/db/enums.py |
Adds READ_USER_GROUPS permission and expands permission definitions. Implements permission expansion logic to derive implied permissions from granted ones. |
EE CC Pair Error Handlingbackend/ee/onyx/server/documents/cc_pair.py |
Replaces HTTPException with OnyxError for permission-related failures. Maps HTTP status codes to semantic error codes (INSUFFICIENT_PERMISSIONS, CONFLICT, INTERNAL_ERROR). |
Backend Auth & User Managementbackend/onyx/auth/users.pybackend/onyx/auth/schemas.pybackend/onyx/auth/api_key.pybackend/onyx/db/auth.pybackend/onyx/db/models.py |
Refactors user role handling to support nullable roles. Updates user creation and API key role assignment to use permission-based defaults. Adds role value serialization. |
Admin Panel Permission Gatesbackend/onyx/server/documents/cc_pair.pybackend/onyx/server/features/document_set/api.pybackend/onyx/server/documents/connector.pybackend/onyx/server/documents/credential.pybackend/onyx/server/manage/llm/api.pybackend/onyx/server/manage/administrative.pybackend/onyx/server/manage/discord_bot/api.pybackend/onyx/server/manage/slack_bot.pybackend/onyx/server/features/tool/api.pybackend/onyx/server/features/persona/api.pybackend/onyx/server/features/oauth_config/api.pybackend/onyx/server/api_key/api.pybackend/onyx/server/pat/api.pybackend/onyx/server/onyx_api/ingestion.pybackend/onyx/server/federated/api.pybackend/ee/onyx/server/user_group/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/ee/onyx/server/token_rate_limits/api.py |
Replaces role-based access checks with permission-based dependency injection. Uses require_permission() for FULL_ADMIN_PANEL_ACCESS and current_curator_or_admin_user for curator-level operations. |
Database Query & Filteringbackend/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/llm.pybackend/onyx/db/notification.pybackend/onyx/db/persona.pybackend/ee/onyx/db/user_group.pybackend/ee/onyx/db/token_limit.pybackend/ee/onyx/db/analytics.pybackend/ee/onyx/db/license.py |
Refactors permission checks to use has_permission() and get_effective_permissions(). Removes legacy role-based filtering logic. Simplifies curator/admin role checks. |
LLM Provider Access Controlbackend/onyx/llm/factory.pybackend/onyx/db/user_preferences.py |
Updates LLM provider access logic to accept is_admin boolean instead of deriving from user role. Removes role-to-account-type mapping. |
Error Handling & Codesbackend/onyx/error_handling/error_codes.py |
Adds BAD_REQUEST and DOCUMENT_SET_NOT_FOUND error codes for semantic error responses. |
Database Migrationsbackend/alembic/versions/c8e316473aaa_make_user_role_nullable.py |
Adds migration to make user role column nullable, supporting permission-based role assignment. |
Integration Tests - Permission Matrixbackend/tests/integration/tests/permissions/_access_matrix.py, test_add_agents.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 |
Adds comprehensive permission-based access matrix tests for all admin panel features. Replaces legacy role-based permission tests. |
Integration Tests - Cleanupbackend/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_user_role_permissions.py, test_whole_curator_flow.py |
Removes obsolete role-based permission tests replaced by new permission matrix tests. |
Integration Tests - Fixtures & Utilitiesbackend/tests/integration/tests/permissions/conftest.pybackend/tests/integration/tests/permissions/test_auth_permission_propagation.pybackend/tests/integration/tests/permissions/test_file_connector_permissions.pybackend/tests/integration/tests/permissions/test_admin_access.pybackend/tests/integration/common_utils/managers/user.pybackend/tests/integration/common_utils/managers/user_group.pybackend/tests/integration/common_utils/managers/api_key.py |
Updates test fixtures and utilities to support permission-based access control. Adds user group manager methods. Refactors user role verification. |
Integration Tests - User & Authbackend/tests/integration/tests/users/test_password_signup_upgrade.pybackend/tests/integration/tests/users/test_user_pagination.pybackend/tests/integration/tests/users/test_slack_user_deactivation.pybackend/tests/integration/tests/users/test_default_group_assignment.pybackend/tests/integration/tests/api_key/test_api_key.pybackend/tests/integration/tests/auth/test_saml_user_conversion.pybackend/tests/integration/tests/chat/test_chat_session_access.py |
Updates user and auth tests to work with nullable roles and permission-based access. Adds user group assignment verification. |
Integration Tests - Otherbackend/tests/integration/tests/query_history/test_query_history.pybackend/tests/integration/tests/query_history/utils.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/llm_provider/test_llm_provider.pybackend/tests/integration/multitenant_tests/syncing/test_search_permissions.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/tests/scim/test_scim_groups.pybackend/tests/integration/tests/scim/test_scim_users.pybackend/tests/integration/tests/usergroup/test_usergroup_syncing.pybackend/tests/integration/conftest.py |
Updates various integration tests to use permission-based access and user group assignment. Adds API key creation for permission-gated endpoints. |
Unit Testsbackend/tests/unit/onyx/auth/test_permissions.pybackend/tests/unit/onyx/auth/test_jwt_provisioning.pybackend/tests/unit/onyx/auth/test_user_registration.pybackend/tests/unit/onyx/server/test_full_user_snapshot.pybackend/tests/unit/onyx/server/scim/conftest.pybackend/tests/external_dependency_unit/db/test_user_account_type.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_api_base.pybackend/tests/external_dependency_unit/llm/test_llm_provider_called.pybackend/tests/external_dependency_unit/conftest.pybackend/tests/external_dependency_unit/connectors/google_drive/test_google_drive_group_sync.pybackend/tests/external_dependency_unit/craft/conftest.pybackend/tests/daily/conftest.py |
Updates unit tests to support nullable roles and permission-based access. Adds permission expansion tests. |
User Management APIbackend/onyx/server/manage/users.py, models.py |
Removes set-user-role and get-user-role endpoints. Updates user response models to include effective_permissions. Refactors user snapshot generation. |
Frontend - Permission Systemweb/src/lib/permissions.ts, permissions.test.ts |
Adds frontend permission checking utilities and tests. Implements hasPermission() and getFirstPermittedAdminRoute() helpers. |
Frontend - Admin Routes & Sidebarweb/src/lib/admin-routes.tsweb/src/lib/admin-sidebar-utils.tsweb/src/sections/sidebar/AdminSidebar.tsxweb/src/sections/sidebar/AppSidebar.tsxweb/src/sections/sidebar/CreateConnectorSidebar.tsxweb/src/app/admin/documents/sets/DocumentSetCreationForm.tsxweb/src/app/admin/connector/[ccPairId]/page.tsxweb/src/app/craft/v1/configure/page.tsx |
Refactors sidebar visibility and admin route access to use permission-based checks. Adds permission-gated feature flags. Removes role-based sidebar filtering. |
Frontend - User Management UIweb/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/refresh-pages/admin/UsersPage/interfaces.tsweb/src/components/admin/users/SignedUpUserTable.tsxweb/src/refresh-pages/admin/UsersPage/UserRoleCell.tsx |
Removes user role management UI (role dropdown, role cell). Replaces with account type display. Removes setUserRole API call. Updates user filters and modals. |
Frontend - Service Accounts & Groupsweb/src/refresh-pages/admin/ServiceAccountsPage/index.tsxweb/src/refresh-pages/admin/ServiceAccountsPage/ApiKeyFormModal.tsxweb/src/refresh-pages/admin/ServiceAccountsPage/interfaces.tsweb/src/refresh-pages/admin/GroupsPage/shared.tsxweb/src/refresh-pages/admin/GroupsPage/useGroupMemberCandidates.tsweb/src/refresh-pages/admin/GroupsPage/EditGroupPage.tsxweb/src/refresh-pages/admin/GroupsPage/CreateGroupPage.tsxweb/src/refresh-pages/admin/GroupsPage/GroupPermissionsSection.tsxweb/src/refresh-pages/admin/GroupsPage/interfaces.ts |
Updates service account and group management to use permission-based access. Adds group permissions section. Refactors role handling in group member candidates. |
Frontend - Auth & User Contextweb/src/providers/UserProvider.tsxweb/src/lib/auth/requireAuth.tsweb/src/hooks/useAdminUsers.tsweb/src/hooks/useUserCounts.ts |
Updates user context to derive isAdmin from permission checks. Removes role-based allowlist. Updates user counts to use role_counts field. |
Frontend - Components & Pagesweb/src/components/admin/ClientLayout.tsxweb/src/components/admin/ClientLayout.test.tsxweb/src/components/admin/connectors/AccessTypeGroupSelector.tsxweb/src/components/IsPublicGroupSelector.tsxweb/src/components/ConnectorMultiSelect.tsxweb/src/components/GenericMultiSelect.tsxweb/src/refresh-pages/SettingsPage.tsxweb/src/refresh-pages/AgentsNavigationPage.tsxweb/src/refresh-pages/AgentEditorPage.tsxweb/src/refresh-pages/AppPage.tsxweb/src/refresh-pages/admin/AgentsPage/AgentRowActions.tsxweb/src/sections/cards/AgentCard.tsxweb/src/sections/modals/ShareAgentModal.tsxweb/src/sections/modals/llmConfig/shared.tsxweb/src/sections/onboarding/OnboardingFlow.tsxweb/src/refresh-components/popovers/ActionsPopover/index.tsx |
Updates components to use permission-based access checks via hasPermission(). Removes role-based visibility logic. Adds permission-gated feature display. |
Frontend - E2E Testsweb/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-based access gating. Updates API client with permission management methods. Refactors user role setup in global setup. |
Frontend - Typesweb/src/lib/types.ts |
Updates UserRole enum with new roles (GLOBAL_CURATOR, LIMITED, SLACK_USER, EXT_PERM_USER). Adds effective_permissions field to user snapshots. Removes invalid role hover text. |
Frontend - Admin Routes Configweb/src/lib/admin-routes.ts |
Expands admin routes configuration with permission-based feature flags and route definitions. |
Sequence Diagram
sequenceDiagram
participant User
participant Frontend
participant API
participant AuthMiddleware
participant PermissionEngine
participant Database
User->>Frontend: Login
Frontend->>API: POST /auth/login
API->>AuthMiddleware: Validate credentials
AuthMiddleware->>Database: Fetch user
Database-->>AuthMiddleware: User record
AuthMiddleware->>PermissionEngine: Get effective permissions
PermissionEngine->>Database: Fetch user groups
Database-->>PermissionEngine: Group memberships
PermissionEngine->>Database: Fetch group permissions
Database-->>PermissionEngine: Permission list
PermissionEngine-->>AuthMiddleware: Effective permissions
AuthMiddleware-->>API: User + permissions
API-->>Frontend: Auth token + user snapshot
Frontend->>Frontend: Check hasPermission(MANAGE_LLMS)
Frontend->>Frontend: Render LLM admin panel
User->>Frontend: Click LLM settings
Frontend->>API: GET /manage/llm
API->>AuthMiddleware: Validate request
AuthMiddleware->>PermissionEngine: Check MANAGE_LLMS
PermissionEngine-->>AuthMiddleware: Permission granted
AuthMiddleware-->>API: Proceed
API->>Database: Fetch LLM configs
Database-->>API: LLM list
API-->>Frontend: LLM data
Frontend-->>User: Display LLM settings
Dig Deeper With Commands
/review <file-path> <function-optional>/chat <file-path> "<question>"/roast <file-path>
Runs only when explicitly triggered.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirror of upstream onyx-dot-app#10173 for benchmark. Do not merge.
Summary by MergeMonkey