Skip to content

Commit

Permalink
Fix: auth in plugin runs list
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraggle committed Mar 5, 2025
1 parent 4ef1a09 commit a0c2e92
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions front/pages/api/poke/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function handler(
>,
session: SessionWithUser
): Promise<void> {
const auth = await Authenticator.fromSuperUserSession(session, null);
let auth = await Authenticator.fromSuperUserSession(session, null);
if (!auth.isDustSuperUser()) {
return apiError(req, res, {
status_code: 404,
Expand All @@ -34,7 +34,7 @@ async function handler(

switch (req.method) {
case "GET": {
const { resourceType, resourceId } = req.query;
const { resourceType, resourceId, workspaceId } = req.query;
if (
typeof resourceType !== "string" ||
!isSupportedResourceType(resourceType)
Expand All @@ -58,6 +58,21 @@ async function handler(
});
}

if (workspaceId && typeof workspaceId !== "string") {
return apiError(req, res, {
status_code: 400,
api_error: {
type: "invalid_request_error",
message: "Invalid workspace id type.",
},
});
}

// If the run targets a specific workspace, use a workspace-scoped authenticator.
if (workspaceId) {
auth = await Authenticator.fromSuperUserSession(session, workspaceId);
}

const plugins = pluginManager.getPluginsForResourceType(resourceType);

const resource = resourceId
Expand Down

0 comments on commit a0c2e92

Please sign in to comment.