We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f78c199 commit 11364e5Copy full SHA for 11364e5
1 file changed
src/auth.rs
@@ -89,11 +89,19 @@ pub fn validate_jwt(jwt: &str) -> Result<i64, String> {
89
let Some(secret) = SECRET_KEY.get() else {
90
return Err("Auth module not initialized".to_string());
91
};
92
+
93
let key = DecodingKey::from_secret(secret);
94
let validation = get_validator(None);
95
let Ok(token) = jsonwebtoken::decode::<Claims>(jwt, &key, &validation) else {
96
return Err("Bad JWT".to_string());
97
98
99
+ // I don't 100% trust this crate to validate the expiration timestamp, so do it manually
100
+ let now = get_current_timestamp();
101
+ if token.claims.exp < now {
102
+ return Err("Expired JWT".to_string());
103
+ }
104
105
match token.claims.sub.parse() {
106
Ok(id) => Ok(id),
107
Err(e) => Err(format!("Bad account ID: {}", e)),
0 commit comments