Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(api): reject unauthenticated cookie fallback in asset auth

Tin50806f19860e
diff --git a/apps/api/src/utils/authenticate-api-request.ts b/apps/api/src/utils/authenticate-api-request.ts
index 7bf060906..a7d299bc7 100644
--- a/apps/api/src/utils/authenticate-api-request.ts
+++ b/apps/api/src/utils/authenticate-api-request.ts
@@ -27,13 +27,8 @@ function parseBearerToken(authHeader: string | undefined): {
return { token: null, malformed: true };
}
- const token = match[1]?.trim();
- if (!token) {
- return { token: null, malformed: true };
- }
-
return {
- token,
+ token: match[1],
malformed: false,
};
}
@@ -110,5 +105,9 @@ export async function resolveAssetBearerOrCookie(c: Context): Promise<{
const sessionResult = await auth.api.getSession({
headers: c.req.raw.headers,
});
- return { userId: sessionResult?.user?.id ?? "" };
+ if (!sessionResult?.user) {
+ throw new HTTPException(401, { message: "Unauthorized" });
+ }
+
+ return { userId: sessionResult.user.id };
}