mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-10 20:02:26 +00:00
check resource id on verify access token
This commit is contained in:
@@ -13,10 +13,12 @@ import { sha256 } from "@oslojs/crypto/sha2";
|
||||
|
||||
export async function verifyResourceAccessToken({
|
||||
accessToken,
|
||||
accessTokenId
|
||||
accessTokenId,
|
||||
resourceId
|
||||
}: {
|
||||
accessToken: string;
|
||||
accessTokenId?: string;
|
||||
resourceId?: number; // IF THIS IS NOT SET, THE TOKEN IS VALID FOR ALL RESOURCES
|
||||
}): Promise<{
|
||||
valid: boolean;
|
||||
error?: string;
|
||||
@@ -100,6 +102,13 @@ export async function verifyResourceAccessToken({
|
||||
};
|
||||
}
|
||||
|
||||
if (resourceId && resource.resourceId !== resourceId) {
|
||||
return {
|
||||
valid: false,
|
||||
error: "Resource ID does not match"
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
valid: true,
|
||||
tokenItem,
|
||||
|
||||
@@ -209,7 +209,8 @@ export async function verifyResourceSession(
|
||||
const { valid, error, tokenItem } = await verifyResourceAccessToken(
|
||||
{
|
||||
accessToken,
|
||||
accessTokenId
|
||||
accessTokenId,
|
||||
resourceId: resource.resourceId
|
||||
}
|
||||
);
|
||||
|
||||
@@ -244,7 +245,8 @@ export async function verifyResourceSession(
|
||||
const { valid, error, tokenItem } = await verifyResourceAccessToken(
|
||||
{
|
||||
accessToken,
|
||||
accessTokenId
|
||||
accessTokenId,
|
||||
resourceId: resource.resourceId
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user