Closed pshuchuan closed 4 months ago
Google translated the title but there is automatic leeway for the validation.
I have the same problem. During one minute after expiration, the token still works.
2024-03-25T16:58:07.508497Z DEBUG middlewares: Access token: eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJleHAiOjE3MTEzODU4MzEsImlhdCI6MTcxMTM4NTUzMSwic3ViIjoiNjYwMDY2NTFlYzQ1YzY5NzJhNzlkZmI5In0.bA7NWrKaw8cMBid4gNQ89bAi83DFsS9kw0qVvaECoisuLl62AYZ6ecA-H5ce1DTuWFE4VPdb7OKf5tanAz1rDg 2024-03-25T16:58:07.512103Z DEBUG middlewares: Claims: Claims { exp: 1711385831, iat: 1711385531, sub: "66006651ec45c6972a79dfb9" }
Google translated the title but there is automatic leeway for the validation.
Oh, i see
[derive(Debug, Serialize, Deserialize)]
pub struct Claims { id:i32, email:String, exp: u64, }
pub fn token(id:i32,email:String) -> String{ let key = b"hmhometoken"; println!("加30秒之前:{}",Utc::now().timestamp()); let expiration_time = Utc::now() + Duration::try_seconds(20).unwrap();
}
pub fn parse_token(token: String) -> Result<Claims, MyError> { let key = b"hmhometoken"; let mut validation = Validation::new(Algorithm::HS512); validation.validate_exp = true;
}