Skip to content

Add key removal functions to JWTKeyCollection#240

Merged
ptoffy merged 5 commits into
mainfrom
key-removal
Mar 16, 2026
Merged

Add key removal functions to JWTKeyCollection#240
ptoffy merged 5 commits into
mainfrom
key-removal

Conversation

@ptoffy

@ptoffy ptoffy commented Feb 9, 2026

Copy link
Copy Markdown
Member

As discussed in #239, key removal functions can be helpful to implement key rotation. A key rotation example will follow.
APIs:

  • clearDefault(): removes the default signer (might still be in the collection though not as default, so its kid must be specified to use it)
  • removeAll(except:, clearingDefault:): removes all signers besides the ones specified in the list and also clears the default if the parameter set to true
  • remove(kid:): removes the specified kid from the list (without considering the default)

@ptoffy ptoffy requested a review from 0xTim February 9, 2026 11:38
Comment thread Sources/JWTKit/JWTKeyCollection.swift
Comment thread Sources/JWTKit/JWTKeyCollection.swift Outdated
Comment thread Tests/JWTKitTests/JWTKitTests.swift
@codecov

codecov Bot commented Feb 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.21%. Comparing base (2681975) to head (f00a7ae).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Sources/JWTKit/JWTKeyCollection.swift 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #240      +/-   ##
==========================================
+ Coverage   82.00%   82.21%   +0.20%     
==========================================
  Files          61       61              
  Lines        1434     1456      +22     
==========================================
+ Hits         1176     1197      +21     
- Misses        258      259       +1     
Files with missing lines Coverage Δ
Sources/JWTKit/JWTKeyCollection.swift 93.57% <95.45%> (+0.47%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptoffy ptoffy requested a review from gwynne February 10, 2026 10:25
@ptoffy ptoffy mentioned this pull request Feb 10, 2026
Comment thread Sources/JWTKit/JWTKeyCollection.swift
Comment thread Sources/JWTKit/JWTKeyCollection.swift
Comment thread Sources/JWTKit/JWTKeyCollection.swift
@0xTim

0xTim commented Feb 24, 2026

Copy link
Copy Markdown
Member

@ptoffy some doc clarifications still needed here

@ptoffy ptoffy merged commit aa60a21 into main Mar 16, 2026
33 of 34 checks passed
@ptoffy ptoffy deleted the key-removal branch March 16, 2026 15: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