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