{"record":{"id":"dbcc5658d72897a9","repo":"apolloconfig/apollo","slug":"super-admin-permission-is-required","errorCode":null,"errorMessage":"Super admin permission is required","messagePattern":"Super admin permission is required","errorType":"exception","errorClass":"AccessDeniedException","httpStatus":403,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ClusterController.java","lineNumber":112,"sourceCode":"  @Override\n  public ResponseEntity<Void> deleteCluster(String env, String appId, String clusterName,\n      String operator) {\n    requireDeleteClusterPermission(appId);\n    String resolvedOperator = resolveOperator(operator);\n\n    clusterOpenApiService.deleteCluster(env, appId, clusterName, resolvedOperator);\n    return ResponseEntity.ok().build();\n  }\n\n  private void requireDeleteClusterPermission(String appId) {\n    String authType = UserIdentityContextHolder.getAuthType();\n    if (UserIdentityConstants.USER.equals(authType)) {\n      // Keep Portal UI behavior aligned with the legacy WebAPI delete path, which required\n      // super-admin permission for cluster deletion.\n      if (unifiedPermissionValidator.isSuperAdmin()) {\n        return;\n      }\n      throw new AccessDeniedException(\"Super admin permission is required\");\n    }\n    if (UserIdentityConstants.CONSUMER.equals(authType)) {\n      // Existing OpenAPI consumers use app-scoped authorization here. Preserve that public\n      // token boundary while keeping the Portal USER path compatible with the legacy WebAPI.\n      if (unifiedPermissionValidator.isAppAdmin(appId)) {\n        return;\n      }\n      throw new AccessDeniedException(\"App admin permission is required\");\n    }\n    if (UserIdentityConstants.USER_TOKEN.equals(authType)) {\n      if (unifiedPermissionValidator.isSuperAdmin()) {\n        return;\n      }\n      throw new AccessDeniedException(\"Super admin permission is required\");\n    }\n    throw new AccessDeniedException(\"Access is denied\");\n  }\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ClusterController.java#L94-L130","documentation":"Thrown by ClusterController.requireDeleteClusterPermission in the USER branch when an interactive Portal UI user attempts to delete a cluster but is not a super admin. Apollo intentionally aligns this path with the legacy WebAPI behavior that required super-admin for cluster deletion. Maps to HTTP 403 AccessDeniedException.","triggerScenarios":"DELETE /openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName} called through the Portal session (authType=USER) by a user who does not pass unifiedPermissionValidator.isSuperAdmin().","commonSituations":"A regular app admin or namespace editor attempts to delete a cluster via the Portal UI or an API call using their browser session. Cluster deletion is intentionally restricted to super admins because it cascades across all environments and namespaces.","solutions":["Request super-admin role for the user from the Apollo system administrator, or have a super admin perform the deletion.","If cluster deletion is genuinely needed by non-super-admins, consider whether the resource can be disabled instead of deleted.","Verify the user is logged in under the correct account — sometimes a test or service account session is active instead of the admin account."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before calling delete cluster via Portal session, check super-admin status\n// This requires a separate API or Portal permission check\nif (!currentUserIsSuperAdmin()) {\n    // surface a clear message to the user or skip the operation\n    throw new IllegalStateException(\"Cluster deletion requires super-admin role. Contact your Apollo administrator.\");\n}","typeGuard":null,"tryCatchPattern":"// Catch AccessDeniedException from the delete call\ntry {\n    client.delete(\"/openapi/v1/envs/\" + env + \"/apps/\" + appId + \"/clusters/\" + clusterName);\n} catch (AccessDeniedException e) {\n    // Inform the user they need super-admin privileges\n    showUserError(\"Cluster deletion requires super-admin permission. Please contact your system administrator.\");\n}","preventionTips":["Hide or disable the delete-cluster action in the UI for non-super-admin users.","Document that cluster deletion is super-admin-only in your team's Apollo usage guide.","Route cluster deletion requests through an approval workflow rather than direct API calls."],"tags":["authorization","openapi","cluster","permissions","super-admin","portal","access-control","http-403"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}