Fix code quality: trailing whitespace, unused imports, clippy warnings
- Fix trailing whitespace in kex.rs and s3.rs - Add missing KexProposal import in kex_complete.rs - Auto-fix clippy warnings across all crates - All 153 tests pass
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use anyhow::Result;
|
||||
use crate::acl::AccessControlList;
|
||||
use anyhow::Result;
|
||||
|
||||
pub struct AuthManager {
|
||||
acl: AccessControlList,
|
||||
@@ -9,26 +9,26 @@ impl AuthManager {
|
||||
pub fn new(acl: AccessControlList) -> Self {
|
||||
AuthManager { acl }
|
||||
}
|
||||
|
||||
|
||||
pub fn authenticate(&self, username: &str, password: Option<&str>) -> Result<bool> {
|
||||
if self.acl.guest_access && password.is_none() {
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
|
||||
if password.is_none() {
|
||||
return Err(anyhow::anyhow!("Password required for user {}", username));
|
||||
}
|
||||
|
||||
|
||||
if self.acl.get_user(username).is_none() {
|
||||
return Err(anyhow::anyhow!("User {} not in ACL", username));
|
||||
}
|
||||
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
|
||||
pub fn check_permission(&self, username: &str, action: &str) -> Result<bool> {
|
||||
let require_write = action == "write" || action == "delete" || action == "create";
|
||||
|
||||
|
||||
if !self.acl.has_access(username, require_write) {
|
||||
return Err(anyhow::anyhow!(
|
||||
"User {} does not have {} permission",
|
||||
@@ -36,15 +36,15 @@ impl AuthManager {
|
||||
action
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
|
||||
pub fn get_acl(&self) -> &AccessControlList {
|
||||
&self.acl
|
||||
}
|
||||
|
||||
|
||||
pub fn update_acl(&mut self, acl: AccessControlList) {
|
||||
self.acl = acl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user