fix: require admin role for destructive project mutations in GraphQL API#14050
Draft
mikeldking wants to merge 1 commit into
Draft
fix: require admin role for destructive project mutations in GraphQL API#14050mikeldking wants to merge 1 commit into
mikeldking wants to merge 1 commit into
Conversation
When auth is enabled, deleteProject, clearProject, and patchProject only checked IsNotViewer, allowing any MEMBER to delete or wipe all projects and their trace data. Add IsAdminIfAuthEnabled to these mutations, matching the REST API where PUT/DELETE /v1/projects require admin. createProject remains member-allowed, matching POST /v1/projects. Also hide the corresponding UI affordances (delete/clear/remove-data menu items and the project settings edit button) from non-admin users, and add role-based integration tests for the four project mutations. Fixes #14047 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NUkuh6drCcqkwDMzKm9crm
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
resolves #14047
Summary
When
PHOENIX_ENABLE_AUTH=true, the GraphQL mutationsdeleteProject,clearProject, andpatchProjectonly checkedIsNotViewer, so any authenticated MEMBER could delete or wipe every project (and all associated traces, evaluations, and experiment data) in the instance. The equivalent REST endpoints (PUT/DELETE /v1/projects/...) already require admin viarequire_admin.Changes
src/phoenix/server/api/mutations/project_mutations.py): addIsAdminIfAuthEnabledto thepermission_classesofdeleteProject,clearProject, andpatchProject, matching the REST API and other sensitive GraphQL mutations.createProjectkeepsIsNotVieweronly, matchingPOST /v1/projectswhich is member-allowed. When auth is disabled, behavior is unchanged (IsAdminIfAuthEnabledpasses).useViewerCanManageProjectshook (admin-only, consistent withuseViewerCanManageRetentionPolicyetc.); the project action menu now hides Clear All Data / Remove Data / Delete for non-admins, and the project settings Edit button (patchProject) is hidden for non-admins.tests/integration/auth/test_auth.py): newTestProjectMutationPermissionsverifying per role (viewer/member/admin/default admin) thatcreateProjectis member-allowed while the three destructive mutations are admin-only.🤖 Generated with Claude Code
https://claude.ai/code/session_01NUkuh6drCcqkwDMzKm9crm
Generated by Claude Code