show sso page in browser for gateway resource

This commit is contained in:
miloschwartz
2026-08-12 11:32:22 -04:00
parent 83035753af
commit 115c3cbf07
8 changed files with 45 additions and 58 deletions
+4 -10
View File
@@ -329,16 +329,10 @@ export async function verifyResourceSession(
// Only offer a browser redirect to clients that can actually follow one and log in
// (an interactive browser). Non-browser clients (curl, scripts, bots, etc.) just get
// an unauthorized response from Badger instead of a login redirect URL.
// Inference browsers go to the dashboard keys page (not back to the inference host)
// so a valid session cannot create a redirect loop.
const redirectPath = clientIsBrowser
? mode === "inference"
? `/${resource.orgId}/resource/${encodeURIComponent(
resource.resourceGuid
)}/keys`
: `/auth/resource/${encodeURIComponent(
resource.resourceGuid
)}?redirect=${encodeURIComponent(originalRequestURL)}`
? `/auth/resource/${encodeURIComponent(
resource.resourceGuid
)}?redirect=${encodeURIComponent(originalRequestURL)}`
: undefined;
// Virtual API keys for public inference resources (provider-style auth headers).
@@ -414,7 +408,7 @@ export async function verifyResourceSession(
parsedBody.data
);
return notAllowed(res, redirectPath);
return notAllowed(res, redirectPath, resource.orgId);
}
// check for access token in headers
@@ -123,10 +123,12 @@ export async function listMyVirtualApiKeys(
}
let resourceId: number | undefined;
let resourceName: string | undefined;
if (resourceGuid) {
const [resource] = await db
.select({
resourceId: resources.resourceId
resourceId: resources.resourceId,
name: resources.name
})
.from(resources)
.where(
@@ -147,6 +149,7 @@ export async function listMyVirtualApiKeys(
}
resourceId = resource.resourceId;
resourceName = resource.name;
}
const { key: userKeyRow } = await getOrCreateUserVirtualApiKey({
@@ -203,7 +206,8 @@ export async function listMyVirtualApiKeys(
userKey: toKeyWithResources(userKeyRow, resourceIdsByKey),
manualKeys: manualRows.map((row) =>
toKeyWithResources(row, resourceIdsByKey)
)
),
...(resourceName !== undefined ? { resourceName } : {})
},
success: true,
error: false,
+1
View File
@@ -22,6 +22,7 @@ export type CreateOrEditVirtualApiKeyResponse = {
export type ListMyVirtualApiKeysResponse = {
userKey: VirtualApiKeyWithResources;
manualKeys: VirtualApiKeyWithResources[];
resourceName?: string | null;
};
export type GetMyVirtualApiKeyResponse = {