Skip to content

Commit 0b56253

Browse files
authored
Update JWTKit version (#154)
* Update JWTKit version * Actually update Swift version in mainfest
1 parent 690a134 commit 0b56253

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version:5.10
22
import PackageDescription
33

44
let package = Package(
@@ -13,7 +13,7 @@ let package = Package(
1313
.library(name: "JWT", targets: ["JWT"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/vapor/jwt-kit.git", from: "5.0.0-beta.2"),
16+
.package(url: "https://github.com/vapor/jwt-kit.git", from: "5.0.0-beta.3"),
1717
.package(url: "https://github.com/vapor/vapor.git", from: "4.92.0"),
1818
],
1919
targets: [

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<img src="https://img.shields.io/github/actions/workflow/status/vapor/jwt/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration">
2020
</a>
2121
<a href="https://swift.org">
22-
<img src="https://design.vapor.codes/images/swift59up.svg" alt="Swift 5.9+">
22+
<img src="https://design.vapor.codes/images/swift510up.svg" alt="Swift 5.10+">
2323
</a>
2424
</p>
2525
<br>

Tests/JWTTests/JWTTests.swift

+14-11
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class JWTTests: XCTestCase {
99
defer { app.shutdown() }
1010

1111
// Add HMAC with SHA-256 signer.
12-
await app.jwt.keys.addHS256(key: "secret")
12+
await app.jwt.keys.addHMAC(key: "secret", digestAlgorithm: .sha256)
1313

14-
await app.jwt.keys.addHS256(key: "foo", kid: "a")
15-
await app.jwt.keys.addHS256(key: "bar", kid: "b")
14+
await app.jwt.keys.addHMAC(key: "foo", digestAlgorithm: .sha256, kid: "a")
15+
await app.jwt.keys.addHMAC(key: "bar", digestAlgorithm: .sha256, kid: "b")
1616

1717
app.jwt.apple.applicationIdentifier = "..."
1818
app.get("apple") { req async throws -> HTTPStatus in
@@ -62,7 +62,7 @@ class JWTTests: XCTestCase {
6262
// signature verification here.
6363
// Since we have an ExpirationClaim, we will
6464
// call its verify method.
65-
func verify(using _: JWTAlgorithm) async throws {
65+
func verify(using _: some JWTAlgorithm) async throws {
6666
try self.expiration.verifyNotExpired()
6767
}
6868
}
@@ -124,7 +124,7 @@ class JWTTests: XCTestCase {
124124
defer { app.shutdown() }
125125

126126
// configures an es512 signer using random key
127-
await app.jwt.keys.addES512(key: ES512PrivateKey())
127+
await app.jwt.keys.addECDSA(key: ES512PrivateKey())
128128

129129
// jwt creation using req.jwt.sign
130130
app.post("login") { req async throws -> LoginResponse in
@@ -166,7 +166,7 @@ class JWTTests: XCTestCase {
166166

167167
// create a token from a different signer
168168
let fakeToken = try await JWTKeyCollection()
169-
.addES512(key: ES512PrivateKey()).sign(TestUser(name: "bob"))
169+
.addECDSA(key: ES512PrivateKey()).sign(TestUser(name: "bob"))
170170
try app.testable().test(
171171
.GET, "me", headers: ["authorization": "Bearer \(fakeToken)"]
172172
) { res in
@@ -181,7 +181,7 @@ class JWTTests: XCTestCase {
181181
defer { app.shutdown() }
182182

183183
// configures an es512 signer using random key
184-
await app.jwt.keys.addES512(key: ES512PrivateKey())
184+
await app.jwt.keys.addECDSA(key: ES512PrivateKey())
185185

186186
// jwt creation using req.jwt.sign
187187
app.post("login") { req async throws -> LoginResponse in
@@ -241,7 +241,7 @@ class JWTTests: XCTestCase {
241241
}
242242

243243
// create a token from a different signer
244-
let fakeToken = try await JWTKeyCollection().addES512(key: ES512PrivateKey()).sign(TestUser(name: "bob"))
244+
let fakeToken = try await JWTKeyCollection().addECDSA(key: ES512PrivateKey()).sign(TestUser(name: "bob"))
245245
try app.testable().test(
246246
.GET, "me", headers: ["authorization": "Bearer \(fakeToken)"]
247247
) { res in
@@ -287,7 +287,7 @@ class JWTTests: XCTestCase {
287287
var id: UUID
288288
var userName: String
289289

290-
func verify(using _: JWTAlgorithm) throws {}
290+
func verify(using _: some JWTAlgorithm) throws {}
291291
}
292292

293293
// creates a new application for testing
@@ -324,7 +324,10 @@ class JWTTests: XCTestCase {
324324
-----END RSA PRIVATE KEY-----
325325
"""
326326

327-
try await app.jwt.keys.addRS256(key: Insecure.RSA.PrivateKey(pem: [UInt8](privateKeyString.utf8)))
327+
try await app.jwt.keys.addRSA(
328+
key: Insecure.RSA.PrivateKey(pem: [UInt8](privateKeyString.utf8)),
329+
digestAlgorithm: .sha256
330+
)
328331

329332
app.get { req async throws -> String in
330333
let authorizationPayload = UserPayload(id: UUID(), userName: "John Smith")
@@ -370,7 +373,7 @@ struct LoginCredentials: Content {
370373
struct TestUser: Content, Authenticatable, JWTPayload {
371374
var name: String
372375

373-
func verify(using _: JWTAlgorithm) throws {
376+
func verify(using _: some JWTAlgorithm) throws {
374377
// nothing to verify
375378
}
376379
}

0 commit comments

Comments
 (0)