Add README
This commit is contained in:
22
README.md
Normal file
22
README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Basic JWT
|
||||
|
||||
This crate provide basic functions to:
|
||||
* Sign JWT
|
||||
* Parse and validate JWT
|
||||
|
||||
|
||||
Basic usage:
|
||||
|
||||
```rust
|
||||
let claims = ...; // note : claims must be serializable
|
||||
|
||||
// Generate a key pair. Public and private key are both serializable
|
||||
let (pub_key, priv_key) = generate_ec384_keypair().unwrap();
|
||||
|
||||
// Create a JWT for the given claims (note: standard claims: sub, iss, ...) are not
|
||||
// automatically added if they are missing
|
||||
let jwt = sign_jwt(&priv_key, &claims).expect("Failed to sign JWT!");
|
||||
|
||||
// Validate signed JWT
|
||||
let claims_out = validate_jwt::<Claims>(&pub_key, &jwt).expect("Failed to validate JWT!");
|
||||
```
|
||||
Reference in New Issue
Block a user