Title: fix(webapp): honor RevokedApiKey grace window for public access tokens by ericallam · Pull Request #3464 · triggerdotdev/trigger.dev · GitHub
Open Graph Title: fix(webapp): honor RevokedApiKey grace window for public access tokens by ericallam · Pull Request #3464 · triggerdotdev/trigger.dev
X Title: fix(webapp): honor RevokedApiKey grace window for public access tokens by ericallam · Pull Request #3464 · triggerdotdev/trigger.dev
Description: Summary Follow-up to #3420. PATs (public access tokens) minted before an API key rotation 401'd immediately on the realtime stream endpoints, even though the rotation flow advertises a 24h overlap. This fixes the gap. Root cause PATs are JWTs signed with the env's apiKey at mint time. When that secret is rotated, validatePublicJwtKey (apps/webapp/app/services/realtime/jwtAuth.server.ts) only verifies the signature against environment.parentEnvironment?.apiKey ?? environment.apiKey — i.e. the env's current canonical key. Any PAT in the wild signed with the previous key fails signature verification → 401, even within the grace window. #3420 wired up the grace-window fallback in two places — findEnvironmentByApiKey (raw secret-key auth) and api.v1.auth.jwt.ts (signs new JWTs with the canonical key when minting from an old one) — but the verify path for already-issued PATs was never updated. In a typical app, POST /api/v1/tasks/.../trigger (Bearer secret) keeps working through rotation because that path has the fallback, but GET /realtime/v1/streams/run_*/... and POST /realtime/v1/streams/run_*/input/... 401 for runs that were already in flight when the rotation happened. Fix After the primary validateJWT against the env's current apiKey, fall back to non-expired RevokedApiKey rows for the signing env (parent env when the request is against a child) — but only on the failure path, so the hot success path is unchanged. Uses $replica to match the rest of the auth path. Symmetrical to the findEnvironmentByApiKey two-step from #3420. Changes apps/webapp/app/services/realtime/jwtAuth.server.ts — validateAgainstRevokedApiKeys helper invoked only on !result.ok apps/webapp/app/models/runtimeEnvironment.server.ts — findEnvironmentById also selects parentEnvironment.id so we can scope the revoked-keys lookup to the correct env Test plan E2E verified locally via curl against GET /realtime/v1/runs/{runId} (PAT-authenticated): Pre-rotation, PAT signed with K1 → 200 with run body Simulate rotation (insert RevokedApiKey row + flip env apiKey to K2 in a single transaction, mirroring regenerateApiKey) Same PAT (K1) within grace window → 200 with run body — fallback hits Fresh PAT signed with K2 → 200 — current key still works Set RevokedApiKey.expiresAt to past → 401 — fallback finds no live row Bogus signature (no rotation) → 401 Cleanup verified: env apiKey restored, RevokedApiKey row deleted pnpm run typecheck --filter webapp passes
Open Graph Description: Summary Follow-up to #3420. PATs (public access tokens) minted before an API key rotation 401'd immediately on the realtime stream endpoints, even though the rotation flow advertises a 24h over...
X Description: Summary Follow-up to #3420. PATs (public access tokens) minted before an API key rotation 401'd immediately on the realtime stream endpoints, even though the rotation flow advertises a 24h ...
Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/3464
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0c68b7dd-6145-8efe-d68f-9b8bd11889ab |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D4CC:19D56D:63C7E4E:852E3DE:6AFAF1E4 |
| html-safe-nonce | 7d8dfaf9265615da5c6efc07c72edcade3a1f7bacd1f68e69e9853addcdc7991 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENENDOjE5RDU2RDo2M0M3RTRFOjg1MkUzREU6NkFGQUYxRTQiLCJ2aXNpdG9yX2lkIjoiOTgyNDg3NjkwNzQzODM3MTU2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9ec1bef5768379b929941b3ac4897d7c33ab830cfaa805463853d0c13b0ef0cc |
| hovercard-subject-tag | pull_request:3597448469 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/3464/files |
| twitter:image | https://avatars.githubusercontent.com/u/534?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/534?s=400&v=4 |
| og:image:alt | Summary Follow-up to #3420. PATs (public access tokens) minted before an API key rotation 401'd immediately on the realtime stream endpoints, even though the rotation flow advertises a 24h over... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0178036d8230524a18422872393ab7e708443ae4c2047f758560a2db870c1913 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git |
| octolytics-dimension-user_id | 95297378 |
| octolytics-dimension-user_login | triggerdotdev |
| octolytics-dimension-repository_id | 572570113 |
| octolytics-dimension-repository_nwo | triggerdotdev/trigger.dev |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 572570113 |
| octolytics-dimension-repository_network_root_nwo | triggerdotdev/trigger.dev |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a85e96a83bed7871993e6b1ffda24105928eee17 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width