Swiftpack.co - Package - vapor/jwt

JWT

Documentation Team Chat MIT License Continuous Integration Swift 4.1


Original author

Github

link
Stars: 204
Help us keep the lights on

Dependencies

Releases

3.0.0 - Aug 14, 2018

JWT 3.0 is here 🎉 🔏 JSON Web Token signing and verification (HMAC, RSA)

Docs: https://docs.vapor.codes/3.0/jwt/getting-started/

API Docs: https://api.vapor.codes/jwt/latest/JWT

3.0.0-rc.2.1.2 - May 31, 2018

Fixed:

  • Fixed a potential security issue that made JWT verification vulnerable to timing attacks. JWT verification will now always check all bytes, even if it has already detected a miss.

3.0.0-rc.2.1 - Mar 25, 2018

Fixed:

  • Updated to latest crypto digest methods.

API Docs: https://api.vapor.codes/jwt/3.0.0-rc.2.1/JWT/

Milestone: 3.0.0-rc.2.1

3.0.0-rc.2 - Mar 21, 2018

New:

  • Vapor is now running on Swift NIO!

Milestone

3.0.0-rc.1 - Feb 28, 2018

New:

  • Added RS256, RS384, and RS512 signature support
import Crypto
import JWT

// create public and private key (only public required for verification)
let privateKey: Data = ...
let publicKey: Data = ...
let privateSigner = JWTSigner.rs256(key: .private2048(privateKey))
let publicSigner = JWTSigner.rs256(key: .public2048(publicKey))

// serialize jwt (requires private key)
let payload: TestPayload = ...
var jwt = JWT(payload: payload)
_ = try jwt.sign(using: publicSigner) // throws, can't sign w/ public signer
let data = try jwt.sign(using: privateSigner)

// parse jwt (public and private key work)
let parsed = try JWT<TestPayload>(from: data, verifiedUsing: publicSigner)
let parsed2 = try JWT<TestPayload>(from: data, verifiedUsing: privateSigner) // also works
print(parsed.payload)
print(parsed2.payload)

Milestone