File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,10 +30,8 @@ import {
3030} from "./organizationAccessToken.server" ;
3131import { isPublicJWT , validatePublicJwtKey } from "./realtime/jwtAuth.server" ;
3232import { 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
3836const 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 {
Original file line number Diff line number Diff 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"
Original file line number Diff line number Diff line change 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 ],
You can’t perform that action at this time.
0 commit comments