diff options
| author | KunoiSayami <[email protected]> | 2024-08-30 19:55:36 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2024-08-30 19:55:36 +0800 |
| commit | 1c9133be32345593b64cb4fff7fe28206adb3fb8 (patch) | |
| tree | 58e5a16a651c40d5aa9eec1a8205314ee6c6edef /src | |
| parent | f7506a53b927191f5865a5b9f84c065abd7c1ec7 (diff) | |
chore: Update crates
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/datastructures.rs | 4 | ||||
| -rw-r--r-- | src/main.rs | 16 | ||||
| -rw-r--r-- | src/test.rs | 8 |
3 files changed, 13 insertions, 15 deletions
diff --git a/src/datastructures.rs b/src/datastructures.rs index 29c852c..ef5c8a4 100644 --- a/src/datastructures.rs +++ b/src/datastructures.rs @@ -728,8 +728,8 @@ impl Authorizer for PAMAuthorizer { async fn verify(&self, user: &str, password: &str) -> Result<bool> { let service = self.provider(); - let mut auth = pam::Authenticator::with_password(service).unwrap(); - auth.get_handler() + let mut auth = pam::Client::with_password(service).unwrap(); + auth.conversation_mut() .borrow_mut() .set_credentials(user, password); Ok(auth.authenticate().is_ok() && auth.open_session().is_ok()) diff --git a/src/main.rs b/src/main.rs index de94789..5b10e01 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,12 +71,12 @@ impl<R: BufRead, W: Write> IOModule<R, W> { if ret.unwrap_or(false) { let redis_conn = redis::Client::open("redis://127.0.0.1/")?; let cookie = Cookie::generate(data.get_user()); - let mut conn = redis_conn.get_async_connection().await?; + let mut conn = redis_conn.get_multiplexed_async_connection().await?; conn.set_ex::<_, _, String>( format!("cgit_auth_{}", cookie.get_key()), cookie.get_body(), - cfg.get_config().cookie_ttl as usize, + cfg.get_config().cookie_ttl as u64, ) .await?; @@ -143,7 +143,7 @@ async fn cmd_authenticate_cookie(matches: &ArgMatches, cfg: Config) -> Result<bo } let redis_conn = redis::Client::open("redis://127.0.0.1/")?; - let mut conn = redis_conn.get_async_connection().await?; + let mut conn = redis_conn.get_multiplexed_async_connection().await?; let redis_key = format!("cgit_repo_{}", repo); if !repo.is_empty() && !conn.exists(&redis_key).await? { @@ -180,7 +180,7 @@ async fn cmd_authenticate_cookie(matches: &ArgMatches, cfg: Config) -> Result<bo { conn.expire::<_, bool>( format!("cgit_auth_{}", cookie.get_key()), - cfg.cookie_ttl as usize, + cfg.cookie_ttl as i64, ) .await?; if cookie.eq_body(r.as_str()) { @@ -477,7 +477,7 @@ async fn cmd_repo_user_control(matches: &ArgMatches, cfg: Config, is_delete: boo let user = matches .get_one::<String>("user") .map(|s| s.as_str()) - .unwrap_or(""); + .unwrap_or_default(); let clear_all = is_delete && matches.contains_id("clear-all"); @@ -489,7 +489,7 @@ async fn cmd_repo_user_control(matches: &ArgMatches, cfg: Config, is_delete: boo } let redis_client = redis::Client::open("redis://127.0.0.1/")?; - let mut redis_conn = redis_client.get_async_connection().await?; + let mut redis_conn = redis_client.get_multiplexed_async_connection().await?; let mut conn = SqliteConnection::connect(cfg.get_database_location()).await?; @@ -555,11 +555,9 @@ async fn cmd_repo_user_control(matches: &ArgMatches, cfg: Config, is_delete: boo if !clear_all { println!( - "{} user {} {} repository {} ACL successful", + "{} user {user} {} repository {repo} ACL successful", if is_delete { "Delete" } else { "Add" }, - user, if is_delete { "from" } else { "to" }, - repo, ); } else { println!("Clear all users from repository {} ACL", repo); diff --git a/src/test.rs b/src/test.rs index 7a92407..45900d1 100644 --- a/src/test.rs +++ b/src/test.rs @@ -56,7 +56,7 @@ mod core { async fn async_test_redis() -> anyhow::Result<()> { let redis_conn = redis::Client::open("redis://127.0.0.1/")?; - let mut conn = redis_conn.get_async_connection().await?; + let mut conn = redis_conn.get_multiplexed_async_connection().await?; let s = rand_str(crate::datastructures::COOKIE_LENGTH); conn.set_ex::<_, _, String>("auth_test", &s, 60).await?; @@ -348,7 +348,7 @@ mod core { async fn clear_redis_setting() -> anyhow::Result<()> { let client = redis::Client::open("redis://127.0.0.1")?; - let mut conn = client.get_async_connection().await?; + let mut conn = client.get_multiplexed_async_connection().await?; for key in &["cgit_repo_test", "cgit_repo_repo"] { conn.del::<_, i32>(*key).await?; @@ -376,8 +376,8 @@ mod core { let user = option_env!("pam_user").unwrap_or("user"); let password = option_env!("pam_password").unwrap_or("password"); - let mut auth = pam::Authenticator::with_password(service).unwrap(); - auth.get_handler() + let mut auth = pam::Client::with_password(service).unwrap(); + auth.conversation_mut() .borrow_mut() .set_credentials(user, password); assert!(auth.authenticate().is_ok() && auth.open_session().is_ok()) |
