mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
examples(jwt): Claims.exp represents a UTC timestamp (#760)
For the example to work, it should be an epoch value in the future. See https://github.com/Keats/jsonwebtoken/blob/d8a33def00a61bab12aa5e94ff76d3043d4d474e/README.md?plain=1#L61
This commit is contained in:
@@ -93,7 +93,8 @@ async fn authorize(Json(payload): Json<AuthPayload>) -> Result<Json<AuthBody>, A
|
|||||||
let claims = Claims {
|
let claims = Claims {
|
||||||
sub: "[email protected]".to_owned(),
|
sub: "[email protected]".to_owned(),
|
||||||
company: "ACME".to_owned(),
|
company: "ACME".to_owned(),
|
||||||
exp: 100000,
|
// Mandatory expiry time as UTC timestamp
|
||||||
|
exp: 2000000000, // May 2033
|
||||||
};
|
};
|
||||||
// Create the authorization token
|
// Create the authorization token
|
||||||
let token = encode(&Header::default(), &claims, &KEYS.encoding)
|
let token = encode(&Header::default(), &claims, &KEYS.encoding)
|
||||||
|
|||||||
Reference in New Issue
Block a user