fix admin add user fail

This commit is contained in:
weisd
2025-02-11 10:10:12 +08:00
parent 9861361aee
commit 1c15eac66a
3 changed files with 9 additions and 7 deletions
-2
View File
@@ -45,8 +45,6 @@ fn encrypt<T: aes_gcm::aead::Aead>(
let nonce = T::generate_nonce(rand::thread_rng());
println!("encrypt nonce len {}, {:?}", nonce.len(), &id);
let encryptor = stream.encrypt(&nonce, data).map_err(Error::ErrEncryptFailed)?;
let mut ciphertext = Vec::with_capacity(salt.len() + 1 + nonce.len() + encryptor.len());
+6 -2
View File
@@ -94,6 +94,7 @@ pub async fn check_key_valid(security_token: Option<String>, ak: &str) -> S3Resu
let sys_cred = cred.clone();
// warn!("check_key_valid cred {:?}, as: {:?}", &cred, &ak);
if cred.access_key != ak {
let Ok(iam_store) = iam::get() else {
return Err(S3Error::with_message(
@@ -124,6 +125,9 @@ pub async fn check_key_valid(security_token: Option<String>, ak: &str) -> S3Resu
cred = u.credentials;
}
// warn!("check_key_valid cred {:?}", &cred);
// warn!("check_key_valid security_token {:?}", &security_token);
let claims = check_claims_from_token(&security_token.unwrap_or_default(), &cred)
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("check claims failed {}", e)))?;
@@ -158,8 +162,8 @@ pub fn check_claims_from_token(token: &str, cred: &auth::Credentials) -> S3Resul
return Err(s3_error!(InvalidRequest, "invalid token"));
}
if cred.is_temp() || cred.is_expired() {
return Err(s3_error!(InvalidRequest, "invalid access key is temp or expired"));
if cred.is_temp() && cred.is_expired() {
return Err(s3_error!(InvalidRequest, "invalid access key is temp and expired"));
}
let Some(sys_cred) = get_global_action_cred() else {
+3 -3
View File
@@ -10,9 +10,9 @@ mkdir -p ./target/volume/test
mkdir -p ./target/volume/test{0..4}
# if [ -z "$RUST_LOG" ]; then
# export RUST_LOG="rustfs=debug,ecstore=debug,s3s=debug,iam=debug"
# fi
if [ -z "$RUST_LOG" ]; then
export RUST_LOG="rustfs=debug,ecstore=debug,s3s=debug,iam=debug"
fi
# export RUSTFS_ERASURE_SET_DRIVE_COUNT=5