Skip to content

feat: add support for asymmetrical url signing keys, auth style key rotation and well-known - #1257

Open
itslenny wants to merge 4 commits into
masterfrom
lenny/jwks-support-standby-key-and-asymmetric-keys
Open

feat: add support for asymmetrical url signing keys, auth style key rotation and well-known#1257
itslenny wants to merge 4 commits into
masterfrom
lenny/jwks-support-standby-key-and-asymmetric-keys

Conversation

@itslenny

@itslenny itslenny commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature

What is the current behavior?

  • Only supports symmetric (HMAC) url signing keys
  • No way to create standby keys or swap them (similar to how auth key rotation works)
  • No way to list tenant jwks
  • JWK/JWT includes the mutable kind as a prefix in the kid - this makes swapping keys problematic

What is the new behavior?

  • Remove kind prefix from kid
  • Support generating/using asymmetrical signing keys (ECDSA)
  • Add endpoints to support "auth style" key rotation
    • Create standby signing keys
    • Swap standby signing keys to active (used to sign URLs via api)
    • List jwks
  • Add public .well-known/jwks.json so asymmetric keys can be validated at the gateway

@itslenny
itslenny requested a review from a team as a code owner July 23, 2026 19:25
@blacksmith-sh

This comment has been minimized.

@coveralls

coveralls commented Jul 23, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32506509059

Coverage increased (+0.2%) to 81.408%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 5 uncovered changes across 3 files (129 of 134 lines covered, 96.27%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/storage/events/jwks/jwks-create-signing-secret.ts 2 0 0.0%
src/test/utils/config-change-awaiter.ts 12 10 83.33%
src/internal/auth/jwks/manager.ts 26 25 96.15%
Total (13 files) 134 129 96.27%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 13228
Covered Lines: 11202
Line Coverage: 84.68%
Relevant Branches: 7835
Covered Branches: 5945
Branch Coverage: 75.88%
Branches in Coverage %: Yes
Coverage Strength: 603.57 hits per line

💛 - Coveralls

claude[bot]

This comment was marked as outdated.

@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch 5 times, most recently from 868168d to 385ef32 Compare July 29, 2026 19:31
Comment thread src/internal/auth/jwks/store-pg.ts
@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch from 385ef32 to 81b3ff4 Compare July 31, 2026 21:05
Comment thread src/storage/events/jwks/jwks-roll-url-signing-key.ts Outdated
@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch 3 times, most recently from 911b0a0 to 22eead5 Compare August 4, 2026 20:47
Comment thread src/internal/auth/jwt.ts Outdated
Comment thread src/internal/auth/jwt.ts Outdated
Comment thread src/internal/auth/jwks/manager.ts
Comment thread src/internal/database/tenant.ts
Comment thread src/app.ts
Comment thread src/app.ts Outdated
Comment thread src/internal/auth/jwks/manager.ts Outdated
@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch from 22eead5 to 5d8582b Compare August 7, 2026 17:17
Comment thread src/app.ts
@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch from 5d8582b to 244508d Compare August 7, 2026 17:48
@itslenny
itslenny requested a review from ferhatelmas August 7, 2026 17:53
Comment thread src/http/routes/admin/jwks.ts Outdated
Comment thread src/http/routes/admin/jwks.ts Outdated
Comment thread src/http/routes/admin/jwks.ts Outdated
Comment thread src/internal/auth/jwks/manager.ts
@itslenny
itslenny requested a review from ferhatelmas August 11, 2026 17:13
Comment thread src/internal/auth/jwt.ts Outdated
Comment thread src/internal/database/tenant.ts Outdated
Comment thread src/internal/auth/jwt.ts
Comment thread src/internal/auth/jwt.ts Outdated
@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch from 7168637 to 36ef6d4 Compare August 13, 2026 13:55
@itslenny
itslenny requested a review from ferhatelmas August 13, 2026 13:59
Comment thread src/internal/auth/jwks/kid.ts
Comment thread src/storage/events/jwks/jwks-create-signing-secret.ts
Comment thread src/storage/events/jwks/jwks-create-signing-secret.ts Outdated
Comment on lines 171 to 175
UPDATE tenants_jwks
SET active = $1
WHERE id = $2
AND tenant_id = $3
AND active = $4

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per state machine, it won't be called concurrently or on signing key but shall we add kind to filter to ensure standby?

@itslenny itslenny Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be called on a key of any kind. It is used in rollURlSigningJwk to deactivate the active key. It can also be used to deactivate custom keys that were added which can have any kind (except the reserved ones). Since the kid is unique (primary key) there is no concern of updating the wrong key.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This did make me realize that it's possible to deactivate the current url signing key which would leave the tenant with no url signing key at all. I added a check at the endpoint layer to explicitly prevent this. We can still use the roll endpoint and from an end user perspective they should create a standby, swap, and then deactivate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, this was my concern

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rechecked this, endpoint check can only protect serial calls. If toggleActive is blocked on row lock of concurrent roll, it can deactivate the single signing key. We still need the kind check here to prevent it

@itslenny
itslenny requested a review from ferhatelmas August 14, 2026 19:48
@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch 3 times, most recently from 1ac6475 to 6840d1d Compare August 18, 2026 15:52
Comment thread src/internal/auth/jwt.ts Outdated
Comment thread src/http/routes/admin/jwks.ts Outdated
Comment thread src/http/routes/admin/jwks.ts
Comment thread src/http/routes/admin/jwks.ts Outdated
@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch from 6840d1d to 414ffcb Compare August 20, 2026 19:09
@itslenny
itslenny requested a review from ferhatelmas August 20, 2026 19:15
Comment thread src/internal/auth/jwks/manager.ts Outdated
@itslenny
itslenny force-pushed the lenny/jwks-support-standby-key-and-asymmetric-keys branch from 414ffcb to 5c942b6 Compare August 21, 2026 17:07
@itslenny
itslenny requested a review from ferhatelmas August 21, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants