Upgrade JWT Kit to 5.2.0 with Breaking Changes Migration#61
Open
0xRohit wants to merge 1 commit intovapor-community:mainfrom
Open
Upgrade JWT Kit to 5.2.0 with Breaking Changes Migration#610xRohit wants to merge 1 commit intovapor-community:mainfrom
0xRohit wants to merge 1 commit intovapor-community:mainfrom
Conversation
Update JWT Kit dependency from 4.13.0 to 5.2.0 and migrate all code to use the new JWT Kit 5.x APIs. This includes comprehensive changes to OAuth authentication flow to maintain compatibility. Changes made: - Update Package.swift dependency to JWT Kit 5.2.0 - Migrate RSA key creation from RSAKey.private() to Insecure.RSA.PrivateKey() - Replace JWTSigner with JWTKeyCollection for token signing - Update JWTPayload.verify() method to use async JWTAlgorithm parameter - Convert OAuth token generation to async/await pattern - Add Sendable conformance to OAuthAccessToken for Swift 6 compatibility - Fix deprecated AsyncHTTPClient body.length usage - Add comprehensive JWT functionality test BREAKING CHANGES: - JWT Kit API migration requires Swift 5.7+ - OAuth token generation now uses async/await internally - JWTPayload verification method signature changed Tested: - All builds pass without warnings - JWT token generation verified with test - OAuth authentication flow maintains compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR upgrades the JWT Kit dependency from 4.13.0 to 5.2.0 and migrates all code to use the new JWT Kit 5.x APIs. The migration maintains full backward compatibility for the OAuth authentication flow while adopting the improved security and performance features of JWT Kit 5.x.
Changes Overview
Dependencies
4.13.0to5.2.0Core OAuth Implementation
OAuthServiceAccount.swift:
RSAKey.private()toInsecure.RSA.PrivateKey(pem:)JWTSigner.rs256()withJWTKeyCollectionapproachgenerateJWT()method to be asyncrefresh()method to handle async JWT generation using Task/Promise patternOAuthPayload.swift:
verify()method signature fromverify(using signer: JWTSigner)toverify(using algorithm: some JWTAlgorithm) async throwsOAuthAccessToken.swift:
Sendableprotocol conformance for Swift 6 compatibilityCode Quality Improvements
body.lengthwithbody.contentLengthTesting
Breaking Changes
RSAKey.private(pem:)Insecure.RSA.PrivateKey(pem:)JWTSigner.rs256(key:).sign()JWTKeyCollection().sign()verify(using: JWTSigner)verify(using: JWTAlgorithm) asyncTesting
Migration Impact
For Library Users
For Library Maintainers
File Changes Summary
Core/Sources/Configuration/OAuth/OAuthAccessToken.swift | 2 +-
Core/Sources/Configuration/OAuth/OAuthPayload.swift | 2 +-
Core/Sources/Configuration/OAuth/OAuthServiceAccount.swift | 53 ++++++++--------
Core/Tests/CredentialTests.swift | 64 ++++++++++++++++++-
Package.swift | 2 +-
Storage/Sources/API/StorageObjectAPI.swift | 2 +-
6 files changed, 98 insertions(+), 27 deletions(-)
Verification Steps
swift buildpasses cleanlyswift testpasses with new JWT functionalitytest
Type of Change