Skip to content

Commit dd68bc9

Browse files
committed
fix(webapp): restore scope-auth path and harden auth telemetry
Revert authenticateApiKeyWithScope to rbac.authenticateAuthorizeBearer (the kill switch still applies via the rbac controller), and make the auth telemetry tolerate a missing resolution from test doubles. Also register the v3/apiKeys subpath in core's typesVersions for node10.
1 parent ba03dff commit dd68bc9

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

apps/webapp/app/services/apiAuth.server.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ import {
3030
} from "./organizationAccessToken.server";
3131
import { isPublicJWT, validatePublicJwtKey } from "./realtime/jwtAuth.server";
3232
import { isDefaultDevBranch, sanitizeBranchName } from "@trigger.dev/core/v3/utils/gitBranch";
33-
import {
34-
authenticateBearerWithTelemetry,
35-
observeLegacyBearerAuthentication,
36-
} from "~/services/authTelemetry.server";
33+
import { rbac } from "./rbac.server";
34+
import { observeLegacyBearerAuthentication } from "~/services/authTelemetry.server";
3735

3836
const ClaimsSchema = z.object({
3937
scopes: z.array(z.string()).optional(),
@@ -309,10 +307,13 @@ export async function authenticateApiKeyWithScope(
309307
return { ok: false, status: 401, error: "Invalid or Missing API key" };
310308
}
311309

312-
const result = await authenticateBearerWithTelemetry(request, { allowJWT });
313-
if (!result.ok) return result;
314-
if (!result.ability.can(action, resource)) {
315-
return { ok: false, status: 403, error: "Unauthorized" };
310+
const result = await rbac.authenticateAuthorizeBearer(
311+
request,
312+
{ action, resource },
313+
{ allowJWT }
314+
);
315+
if (!result.ok) {
316+
return result;
316317
}
317318

318319
return {

apps/webapp/app/services/authTelemetry.server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ export async function authenticateBearerWithTelemetry(
4646

4747
try {
4848
const result = await rbac.authenticateBearer(request, options);
49+
// The host LazyController always attaches `resolution`; fall back to the
50+
// format-based classification if a caller (e.g. a test double) omits it.
51+
const resolution = result.resolution ?? classified;
4952
final = {
50-
credentialKind: result.resolution.credentialKind,
51-
lookupPath: result.resolution.lookupPath,
53+
credentialKind: resolution.credentialKind,
54+
lookupPath: resolution.lookupPath,
5255
result: result.ok
5356
? "success"
54-
: result.resolution.lookupPath === "additional_skipped"
57+
: resolution.lookupPath === "additional_skipped"
5558
? "disabled"
5659
: result.status === 403
5760
? "forbidden"

packages/core/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
"v3/jwt": [
153153
"dist/commonjs/v3/jwt.d.ts"
154154
],
155+
"v3/apiKeys": [
156+
"dist/commonjs/v3/apiKeys.d.ts"
157+
],
155158
"v3/runEngineWorker": [
156159
"dist/commonjs/v3/runEngineWorker/index.d.ts"
157160
],

0 commit comments

Comments
 (0)