Merge pull request #551 from AppFlowy-IO/jwt-exp-verify
fix: remove unneeded time verification
This commit is contained in:
commit
6cc46e3779
|
|
@ -48,17 +48,4 @@ impl GoTrueJWTClaims {
|
|||
let token_data = decode::<Self>(token, &DecodingKey::from_secret(secret), &VALIDATION)?;
|
||||
Ok(token_data.claims)
|
||||
}
|
||||
|
||||
pub fn verify_claim(claims: &GoTrueJWTClaims) -> Result<(), jsonwebtoken::errors::Error> {
|
||||
let ts_expiry = claims.exp.ok_or_else(|| {
|
||||
jsonwebtoken::errors::ErrorKind::MissingRequiredClaim("expect exp but not found".to_owned())
|
||||
})?;
|
||||
|
||||
let ts_now = chrono::Utc::now().timestamp();
|
||||
if ts_now > ts_expiry {
|
||||
Err(jsonwebtoken::errors::ErrorKind::ExpiredSignature.into())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,12 +151,5 @@ fn gotrue_jwt_claims_from_token(
|
|||
.map_err(|err| {
|
||||
actix_web::error::ErrorUnauthorized(format!("fail to decode token, error:{}", err))
|
||||
})?;
|
||||
|
||||
GoTrueJWTClaims::verify_claim(&claims).map_err(|err| {
|
||||
actix_web::error::ErrorUnauthorized(format!(
|
||||
"fail to verify token, claims:{}, error:{}",
|
||||
claims, err
|
||||
))
|
||||
})?;
|
||||
Ok(claims)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue