Releases: mikkyang/rust-jwt
Releases · mikkyang/rust-jwt
Remove legacy code
Merge pull request #51 from mikkyang/release/0.9.0
- Fix
issued_at
claim serde attribute - Widen blanket trait implementation of FromBase64 from
DeserializeOwned
toDeserialize
- More detailed errors for token verification
Update RustCrypto Dependencies
Dependency | Old | New |
---|---|---|
base64 | 0.10 | 0.12 |
crypto-mac | 0.7 | 0.8 |
digest | 0.8 | 0.9 |
hmac | 0.7 | 0.8 |
sha2 | 0.8 | 0.9 |
Add `Store` trait
With the Store
trait, you can keep collections of keys indexed by their key ids.
New Token API
- Move all of the previous structs to the
legacy
module - Introduce more idiomatic
Header
,Claims
, andToken
types - Support more algorithms with optional OpenSSL support
- Convenience methods to just sign and verify claims
For most, the following should be enough with their own defined claims types:
With the following key:
let key: Hmac<Sha256> = Hmac::new_varkey(b"some-secret").unwrap();
Signing:
let mut claims = BTreeMap::new();
claims.insert("sub", "someone");
let token_str = claims.sign_with_key(&key).unwrap();
Verification:
let token_str = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzb21lb25lIn0.5wwE1sBrs-vftww_BGIuTVDeHtc1Jsjo-fiHhDwR8m0";
let claims: BTreeMap<String, String> = VerifyWithKey::verify_with_key(token_str, &key).unwrap();
Update (very outdated) dependencies
The only user facing changes are much needed updates to the crypto dependencies, courtesy of #10.
Types from the previous crate, rust-crypto
are replaced with types from various crates from https://github.com/RustCrypto.
For example, replace the type crypto::sha2::Sha256
with sha2::Sha256
.
Additionally, rustc_serialize
has been migrated to serde
from #9.