this repo has no description
at main 747 B view raw
1use super::super::OAuthError; 2use sqlx::PgPool; 3 4pub async fn check_and_record_dpop_jti(pool: &PgPool, jti: &str) -> Result<bool, OAuthError> { 5 let result = sqlx::query!( 6 r#" 7 INSERT INTO oauth_dpop_jti (jti) 8 VALUES ($1) 9 ON CONFLICT (jti) DO NOTHING 10 "#, 11 jti 12 ) 13 .execute(pool) 14 .await?; 15 Ok(result.rows_affected() > 0) 16} 17 18pub async fn cleanup_expired_dpop_jtis( 19 pool: &PgPool, 20 max_age_secs: i64, 21) -> Result<u64, OAuthError> { 22 let result = sqlx::query!( 23 r#" 24 DELETE FROM oauth_dpop_jti 25 WHERE created_at < NOW() - INTERVAL '1 second' * $1 26 "#, 27 max_age_secs as f64 28 ) 29 .execute(pool) 30 .await?; 31 Ok(result.rows_affected()) 32}