Merge branch 'aig' of https://github.com/fosrl/pangolin into aig

This commit is contained in:
miloschwartz
2026-08-12 12:35:30 -04:00
21 changed files with 851 additions and 70 deletions
+17 -4
View File
@@ -104,6 +104,10 @@ export type VerifyUserResponse = {
pangolinVersion?: string;
dontStripSession?: boolean;
clientError?: ClientErrorResponse;
// Set independently of userData so a manual virtual API key with no
// associated user still gets attributed to the key that authenticated
// the request (see the mode === "inference" branch below).
virtualApiKeyId?: string;
};
function notAllowedWithClientError(
@@ -419,7 +423,12 @@ export async function verifyResourceSession(
parsedBody.data
);
return allowed(res, vakUserData, dontStripSession);
return allowed(
res,
vakUserData,
dontStripSession,
key.virtualApiKeyId
);
}
}
@@ -1014,16 +1023,20 @@ async function notAllowed(
function allowed(
res: Response,
userData?: BasicUserData,
dontStripSession?: boolean
dontStripSession?: boolean,
virtualApiKeyId?: string
) {
const baseData =
userData !== undefined && userData !== null
? { valid: true, ...userData, pangolinVersion: APP_VERSION }
: { valid: true, pangolinVersion: APP_VERSION };
const withVirtualApiKey = virtualApiKeyId
? { ...baseData, virtualApiKeyId }
: baseData;
const data = {
data: dontStripSession
? { ...baseData, dontStripSession: true }
: baseData,
? { ...withVirtualApiKey, dontStripSession: true }
: withVirtualApiKey,
success: true,
error: false,
message: "Access allowed",