Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(playground): deny playground execution to users of role VIEWER (#14540)

Hassieb Pakzada7ba05025b29
diff --git a/web/src/features/playground/server/authorizeRequest.ts b/web/src/features/playground/server/authorizeRequest.ts
index 2e20f9c4d1..e6020881f3 100644
--- a/web/src/features/playground/server/authorizeRequest.ts
+++ b/web/src/features/playground/server/authorizeRequest.ts
@@ -3,6 +3,7 @@ import { getServerSession } from "next-auth";
import { getAuthOptions } from "@/src/server/auth";
import { isProjectMemberOrAdmin } from "@/src/server/utils/checkProjectMembershipOrAdmin";
import { ForbiddenError, UnauthorizedError } from "@langfuse/shared";
+import { hasProjectAccess } from "../../rbac/utils/checkProjectAccess";
export type AuthorizeRequestResult = {
userId: string;
@@ -18,5 +19,8 @@ export const authorizeRequestOrThrow = async (
if (!isProjectMemberOrAdmin(session.user, projectId))
throw new ForbiddenError("User is not a member of this project");
+ if (!hasProjectAccess({ session, projectId, scope: "playground:execute" }))
+ throw new ForbiddenError("Insufficient permissions to execute playground.");
+
return { userId: session.user.id };
};
diff --git a/web/src/features/rbac/constants/projectAccessRights.ts b/web/src/features/rbac/constants/projectAccessRights.ts
index 114b270721..c0390cd342 100644
--- a/web/src/features/rbac/constants/projectAccessRights.ts
+++ b/web/src/features/rbac/constants/projectAccessRights.ts
@@ -65,6 +65,8 @@ export const projectScopes = [
"llmTools:CUD",
"llmTools:read",
+ "playground:execute",
+
"comments:CUD",
"comments:read",
@@ -124,6 +126,7 @@ export const projectRoleAccessRights: Record<Role, ProjectScope[]> = {
"llmSchemas:read",
"llmTools:CUD",
"llmTools:read",
+ "playground:execute",
"batchExports:create",
"batchExports:read",
"comments:CUD",
@@ -180,6 +183,7 @@ export const projectRoleAccessRights: Record<Role, ProjectScope[]> = {
"llmSchemas:read",
"llmTools:CUD",
"llmTools:read",
+ "playground:execute",
"batchExports:create",
"batchExports:read",
"comments:CUD",
@@ -226,6 +230,7 @@ export const projectRoleAccessRights: Record<Role, ProjectScope[]> = {
"llmSchemas:CUD",
"llmTools:CUD",
"llmTools:read",
+ "playground:execute",
"batchExports:create",
"batchExports:read",
"comments:CUD",