diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2022-09-10 09:29:23 +0000 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2022-09-10 09:29:23 +0000 |
| commit | eb0c91b62ae10cbf8b6c787313855a9efd63f2f0 (patch) | |
| tree | 4c88bb7bc47476c5656848ccf020229663298c35 /src | |
| parent | f9286bd6daa029b502e3494bdfe0e23ad9fa0922 (diff) | |
Check expiration before sending claims
Diffstat (limited to 'src')
| -rw-r--r-- | src/models/auth.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/models/auth.rs b/src/models/auth.rs index 0c860df..36a0175 100644 --- a/src/models/auth.rs +++ b/src/models/auth.rs @@ -101,6 +101,12 @@ where let token_data = decode::<Claims>(bearer.token(), &KEYS.decoding, &Validation::default()) .map_err(|_| AppError::InvalidToken)?; + let now = Local::now().timestamp() as usize; + + if token_data.claims.exp < now { + return Err(AppError::InvalidToken); + } + Ok(token_data.claims) } } |
