Skip to content

Commit

Permalink
code + comments cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebadob committed Sep 26, 2023
1 parent 05b59f2 commit 33a70fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
42 changes: 3 additions & 39 deletions rauthy-main/src/schedulers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ use std::time::Duration;
use tokio::time;
use tracing::{debug, error, info};

/**
The main scheduler function, where everything is defined.<br>
I runs in its own thread and executes the schedulers synchronously - no async needed here.
One important value is the SCHED_SLEEP_DURATION. This affects the graceful shutdown time of the
application, if it is too high.
*/
pub async fn scheduler_main(data: web::Data<AppState>) {
info!("Starting schedulers");

Expand Down Expand Up @@ -71,33 +64,6 @@ pub async fn db_backup(db: DbPool) {
}
}

// // Cleans up old / expired / already used Authorization Codes
// // Cleanup inside the cache is done automatically with a max entry lifetime of 300 seconds
// pub async fn auth_codes_cleanup(data: web::Data<AppState>) {
// let mut interval = time::interval(Duration::from_secs(60 * 17));
//
// loop {
// interval.tick().await;
//
// debug!("Running auth_codes_cleanup scheduler");
// match DATA_STORE.scan_cf(Cf::AuthCodes).await {
// Ok(bytes) => {
// let del = bytes
// .iter()
// .map(|(_, b)| bincode::deserialize::<AuthCode>(b).unwrap())
// .filter(|code| code.exp < chrono::Local::now().naive_local())
// .collect::<Vec<AuthCode>>();
// for code in del {
// if let Err(err) = code.delete(&data).await {
// error!("Auth Code Cleanup Error: {}", err.message);
// }
// }
// }
// Err(err) => error!("AuthCodes cleanup scheduler error: {}", err.message),
// }
// }
// }

// Cleans up old / expired magic links and deletes users, that have never used their
// 'set first ever password' magic link to keep the database clean in case of an open user registration.
// Runs every 6 hours.
Expand Down Expand Up @@ -206,6 +172,9 @@ pub async fn user_expiry_checker(data: web::Data<AppState>) {
* 60
})
.ok();
if cleanup_after_secs.is_none() {
info!("Auto cleanup for expired users disabled");
}

loop {
interval.tick().await;
Expand Down Expand Up @@ -246,14 +215,9 @@ pub async fn user_expiry_checker(data: web::Data<AppState>) {
);
}

debug!("cleanup_after_secs {:?}", cleanup_after_secs);
// possibly auto-cleanup expired user
if let Some(secs) = cleanup_after_secs {
let expired_since_secs = (exp_ts - now).abs() as u64;
debug!(
"expired_since_secs > sec: {} > {}",
expired_since_secs, secs
);
if expired_since_secs > secs {
info!(
"Auto cleanup for user {} after being expired for {} minutes",
Expand Down
2 changes: 1 addition & 1 deletion rauthy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ SCHED_USER_EXP_MINS=1
# The threshold in minutes after which time the user expiry scheduler should automatically clean up expired users.
# If not set at all, expired users will never be cleaned up automatically.
# default: disabled / not set
SCHED_USER_EXP_DELETE_MINS=2
#SCHED_USER_EXP_DELETE_MINS=7200

#####################################
############# E-MAIL ################
Expand Down

0 comments on commit 33a70fa

Please sign in to comment.