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
+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 {