feat: resource restriction in presign token (#2150)

This commit is contained in:
Ted Liang
2025-12-08 12:55:54 +11:00
committed by GitHub
parent f70b76d8b8
commit dcaecf1fc5
11 changed files with 166 additions and 80 deletions
@@ -41,7 +41,9 @@ export const loader = async ({ request, params }: Route.LoaderArgs) => {
const token = url.searchParams.get('token') || '';
// We also know that the token is valid, but we need the userId + teamId
const result = await verifyEmbeddingPresignToken({ token }).catch(() => null);
const result = await verifyEmbeddingPresignToken({ token, scope: `documentId:${id}` }).catch(
() => null,
);
if (!result) {
throw new Error('Invalid token');
@@ -41,7 +41,9 @@ export const loader = async ({ request, params }: Route.LoaderArgs) => {
const token = url.searchParams.get('token') || '';
// We also know that the token is valid, but we need the userId + teamId
const result = await verifyEmbeddingPresignToken({ token }).catch(() => null);
const result = await verifyEmbeddingPresignToken({ token, scope: `templateId:${id}` }).catch(
() => null,
);
if (!result) {
throw new Error('Invalid token');