René's URL Explorer Experiment


Title: feat(webapp,database): API key rotation grace period by ericallam · Pull Request #3420 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: feat(webapp,database): API key rotation grace period by ericallam · Pull Request #3420 · triggerdotdev/trigger.dev

X Title: feat(webapp,database): API key rotation grace period by ericallam · Pull Request #3420 · triggerdotdev/trigger.dev

Description: Summary Regenerating a RuntimeEnvironment API key no longer immediately invalidates the previous one. Rotation is now overlap-based: the old key keeps working for 24 hours so customers can roll it out in their env vars without downtime, then stops working. Design New RevokedApiKey table (one row per revocation). Holds the archived apiKey, a FK to the env, an expiresAt, and a createdAt. Indexed on apiKey (high-cardinality equality — single-row hits) and on runtimeEnvironmentId. regenerateApiKey wraps both writes in a single $transaction: insert a RevokedApiKey with expiresAt = now + 24h, update the env with the new apiKey/pkApiKey. findEnvironmentByApiKey does a two-step lookup: primary unique-index hit on RuntimeEnvironment.apiKey first; on miss, RevokedApiKey.findFirst({ apiKey, expiresAt: { gt: now } }) with an include: { runtimeEnvironment }. Two-step (not OR-join) keeps the hot path identical to today and puts the fallback cost only on invalid keys. Both lookups use $replica. Admin endpoint POST /admin/api/v1/revoked-api-keys/:id accepts { expiresAt } and updates the row. Setting to now ends the grace window immediately; setting to the future extends it. Modal copy on the regenerate dialog updated — previously warned of downtime, now explains the 24h overlap. Why a separate table instead of columns on RuntimeEnvironment Keeps the hot auth path's primary lookup unchanged — no OR/nullable-apiKey semantics to reason about. Naturally supports multiple in-flight grace windows (regenerate twice in a day → two old keys valid until their independent expiries). FK + cascade cleans up correctly when an env is deleted; nothing to backfill. Test plan Verified locally against hello-world with dev and prod env keys: baseline — current key authenticates (GET /api/v1/runs) → 200 regenerate via UI — DB shows old key in RevokedApiKey with expiresAt ≈ now+24h, env has new key grace window — both old and new keys → 200; bogus key → 401 admin endpoint: expiresAt = now → old key 401 admin endpoint: expiresAt = +1h (after early-expire) → old key 200 again admin endpoint: expiresAt = past → old key 401 admin 400 (invalid body), 404 (unknown id), 401 (missing/non-admin PAT) same flow exercised end-to-end on a PROD-typed env — behavior identical pnpm run typecheck --filter webapp passes

Open Graph Description: Summary Regenerating a RuntimeEnvironment API key no longer immediately invalidates the previous one. Rotation is now overlap-based: the old key keeps working for 24 hours so customers can roll it ...

X Description: Summary Regenerating a RuntimeEnvironment API key no longer immediately invalidates the previous one. Rotation is now overlap-based: the old key keeps working for 24 hours so customers can roll it ...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/3420

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:2fb9bb84-d6d7-cef8-0244-bed346033c81
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC720:2FFF08:63F62BB:862862B:6AFAF8DA
html-safe-nonceb4edf5a2dedcfbc8d8028fba2dd0676c72e72f1487f0aae81af0e8f40872c85f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzIwOjJGRkYwODo2M0Y2MkJCOjg2Mjg2MkI6NkFGQUY4REEiLCJ2aXNpdG9yX2lkIjoiNDMwMjY3OTQ2NTYyNTU4MTc4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacb73a286b565accc9762a9132460bdf0bcc79708f957326f7f0d7c031a341409d
hovercard-subject-tagpull_request:3557223654
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/3420/files
twitter:imagehttps://avatars.githubusercontent.com/u/534?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/534?s=400&v=4
og:image:altSummary Regenerating a RuntimeEnvironment API key no longer immediately invalidates the previous one. Rotation is now overlap-based: the old key keeps working for 24 hours so customers can roll it ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None54f7a6886649661c85eee945cca0773566bfb4065370e0429b7c8f7204184650
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecf8450eb633ec589502c42ff6f4072e40db65da3
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F3420%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F3420%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
triggerdotdevhttps://github.com/triggerdotdev
trigger.devhttps://github.com/triggerdotdev/trigger.dev
Codehttps://github.com/triggerdotdev/trigger.dev
Issues203 (203)https://github.com/triggerdotdev/trigger.dev/issues
Pull requests67 (67)https://github.com/triggerdotdev/trigger.dev/pulls
Discussionshttps://github.com/triggerdotdev/trigger.dev/discussions
Actionshttps://github.com/triggerdotdev/trigger.dev/actions
Projectshttps://github.com/triggerdotdev/trigger.dev/projects
Security and quality39 (39)https://github.com/triggerdotdev/trigger.dev/security
Insightshttps://github.com/triggerdotdev/trigger.dev/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
ericallamhttps://github.com/ericallam
mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
feat/api-key-rotation-grace-periodhttps://github.com/triggerdotdev/trigger.dev/tree/feat/api-key-rotation-grace-period
Conversation 10 https://github.com/triggerdotdev/trigger.dev/pull/3420
Commits 2 https://github.com/triggerdotdev/trigger.dev/pull/3420/commits
Checks 44 https://github.com/triggerdotdev/trigger.dev/pull/3420/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/3420/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
feat(webapp,database): API key rotation grace period https://github.com/triggerdotdev/trigger.dev/pull/3420/files#top
Show all changes 2 commits https://github.com/triggerdotdev/trigger.dev/pull/3420/files
d21217d feat(webapp,database): API key rotation grace period ericallam Apr 20, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3420/commits/d21217d30ec988cf45dcf08f677a6106293aee60
2a63995 fix(webapp): sign public JWTs with env.apiKey, not the raw header key ericallam Apr 20, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3420/commits/2a63995b0eb08b56895d8aea781a1eba4e683f22
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/3420/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
revoked-api-key-grace-period.md https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-38c86b0b74ee505e8354dddfc3545208af121afc97507a0d6f94d611d49114f9
RegenerateApiKeyModal.tsx https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-486d18af567b176a8c8d840d7db417770b39ba828db79d32a559f5f9e1c8cd8a
api-key.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-1208c7eaa60d0167df6a17fc81d9e74f26b49bde8ef27711ddf4b41395278585
runtimeEnvironment.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-15cc1b2976807e5d2a9e65b1565c47ac285fa77a082e0169438173af9b125e21
admin.api.v1.revoked-api-keys.$revokedApiKeyId.ts https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-daf99596e0684511309cc11181956edc6faba80a1591c6d309cd15f89f8d8bd5
api.v1.auth.jwt.ts https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-120338a9c9193a03d5684b1d02215cd407098664ee7da62d352f70d9bfb7673f
migration.sql https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-515207bc95508d7b65b6ab5bb99a76ca7bcbe72613b4e2361f64d1e76c079897
schema.prisma https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
.server-changes/revoked-api-key-grace-period.mdhttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-38c86b0b74ee505e8354dddfc3545208af121afc97507a0d6f94d611d49114f9
View file https://github.com/triggerdotdev/trigger.dev/blob/2a63995b0eb08b56895d8aea781a1eba4e683f22/.server-changes/revoked-api-key-grace-period.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3420/{{ revealButtonHref }}
apps/webapp/app/components/environments/RegenerateApiKeyModal.tsxhttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-486d18af567b176a8c8d840d7db417770b39ba828db79d32a559f5f9e1c8cd8a
View file https://github.com/triggerdotdev/trigger.dev/blob/2a63995b0eb08b56895d8aea781a1eba4e683f22/apps/webapp/app/components/environments/RegenerateApiKeyModal.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3420/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-486d18af567b176a8c8d840d7db417770b39ba828db79d32a559f5f9e1c8cd8a
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-486d18af567b176a8c8d840d7db417770b39ba828db79d32a559f5f9e1c8cd8a
apps/webapp/app/models/api-key.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-1208c7eaa60d0167df6a17fc81d9e74f26b49bde8ef27711ddf4b41395278585
View file https://github.com/triggerdotdev/trigger.dev/blob/2a63995b0eb08b56895d8aea781a1eba4e683f22/apps/webapp/app/models/api-key.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3420/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-1208c7eaa60d0167df6a17fc81d9e74f26b49bde8ef27711ddf4b41395278585
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-1208c7eaa60d0167df6a17fc81d9e74f26b49bde8ef27711ddf4b41395278585
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-1208c7eaa60d0167df6a17fc81d9e74f26b49bde8ef27711ddf4b41395278585
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-1208c7eaa60d0167df6a17fc81d9e74f26b49bde8ef27711ddf4b41395278585
apps/webapp/app/models/runtimeEnvironment.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-15cc1b2976807e5d2a9e65b1565c47ac285fa77a082e0169438173af9b125e21
View file https://github.com/triggerdotdev/trigger.dev/blob/2a63995b0eb08b56895d8aea781a1eba4e683f22/apps/webapp/app/models/runtimeEnvironment.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3420/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-15cc1b2976807e5d2a9e65b1565c47ac285fa77a082e0169438173af9b125e21
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-15cc1b2976807e5d2a9e65b1565c47ac285fa77a082e0169438173af9b125e21
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-15cc1b2976807e5d2a9e65b1565c47ac285fa77a082e0169438173af9b125e21
apps/webapp/app/routes/admin.api.v1.revoked-api-keys.$revokedApiKeyId.tshttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-daf99596e0684511309cc11181956edc6faba80a1591c6d309cd15f89f8d8bd5
View file https://github.com/triggerdotdev/trigger.dev/blob/2a63995b0eb08b56895d8aea781a1eba4e683f22/apps/webapp/app/routes/admin.api.v1.revoked-api-keys.%24revokedApiKeyId.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3420/{{ revealButtonHref }}
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
apps/webapp/app/routes/api.v1.auth.jwt.tshttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-120338a9c9193a03d5684b1d02215cd407098664ee7da62d352f70d9bfb7673f
View file https://github.com/triggerdotdev/trigger.dev/blob/2a63995b0eb08b56895d8aea781a1eba4e683f22/apps/webapp/app/routes/api.v1.auth.jwt.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3420/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-120338a9c9193a03d5684b1d02215cd407098664ee7da62d352f70d9bfb7673f
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-120338a9c9193a03d5684b1d02215cd407098664ee7da62d352f70d9bfb7673f
...ackages/database/prisma/migrations/20260420000000_add_revoked_api_key_table/migration.sqlhttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-515207bc95508d7b65b6ab5bb99a76ca7bcbe72613b4e2361f64d1e76c079897
View file https://github.com/triggerdotdev/trigger.dev/blob/2a63995b0eb08b56895d8aea781a1eba4e683f22/internal-packages/database/prisma/migrations/20260420000000_add_revoked_api_key_table/migration.sql
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3420/{{ revealButtonHref }}
internal-packages/database/prisma/schema.prismahttps://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
View file https://github.com/triggerdotdev/trigger.dev/blob/2a63995b0eb08b56895d8aea781a1eba4e683f22/internal-packages/database/prisma/schema.prisma
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3420/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
https://github.com/triggerdotdev/trigger.dev/pull/3420/files#diff-6b8eefc1da429865c9493bbac9d2c4d00d1cfe2f2231f6474b9692f13b88e419
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3420/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.