mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-28 07:57:01 +00:00
feat: Replace LRU cache with Moka async cache in policy variables (#1166)
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -755,10 +755,10 @@ impl<T: Store> IamSys<T> {
|
||||
|
||||
let (has_session_policy, is_allowed_sp) = is_allowed_by_session_policy(args);
|
||||
if has_session_policy {
|
||||
return is_allowed_sp && (is_owner || combined_policy.is_allowed(args));
|
||||
return is_allowed_sp && (is_owner || combined_policy.is_allowed(args).await);
|
||||
}
|
||||
|
||||
is_owner || combined_policy.is_allowed(args)
|
||||
is_owner || combined_policy.is_allowed(args).await
|
||||
}
|
||||
|
||||
pub async fn is_allowed_service_account(&self, args: &Args<'_>, parent_user: &str) -> bool {
|
||||
@@ -814,15 +814,15 @@ impl<T: Store> IamSys<T> {
|
||||
};
|
||||
|
||||
if sa_str == INHERITED_POLICY_TYPE {
|
||||
return is_owner || combined_policy.is_allowed(&parent_args);
|
||||
return is_owner || combined_policy.is_allowed(&parent_args).await;
|
||||
}
|
||||
|
||||
let (has_session_policy, is_allowed_sp) = is_allowed_by_session_policy_for_service_account(args);
|
||||
if has_session_policy {
|
||||
return is_allowed_sp && (is_owner || combined_policy.is_allowed(&parent_args));
|
||||
return is_allowed_sp && (is_owner || combined_policy.is_allowed(&parent_args).await);
|
||||
}
|
||||
|
||||
is_owner || combined_policy.is_allowed(&parent_args)
|
||||
is_owner || combined_policy.is_allowed(&parent_args).await
|
||||
}
|
||||
|
||||
pub async fn get_combined_policy(&self, policies: &[String]) -> Policy {
|
||||
@@ -857,7 +857,7 @@ impl<T: Store> IamSys<T> {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.get_combined_policy(&policies).await.is_allowed(args)
|
||||
self.get_combined_policy(&policies).await.is_allowed(args).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,7 +883,7 @@ fn is_allowed_by_session_policy(args: &Args<'_>) -> (bool, bool) {
|
||||
let mut session_policy_args = args.clone();
|
||||
session_policy_args.is_owner = false;
|
||||
|
||||
(has_session_policy, sub_policy.is_allowed(&session_policy_args))
|
||||
(has_session_policy, pollster::block_on(sub_policy.is_allowed(&session_policy_args)))
|
||||
}
|
||||
|
||||
fn is_allowed_by_session_policy_for_service_account(args: &Args<'_>) -> (bool, bool) {
|
||||
@@ -909,7 +909,7 @@ fn is_allowed_by_session_policy_for_service_account(args: &Args<'_>) -> (bool, b
|
||||
let mut session_policy_args = args.clone();
|
||||
session_policy_args.is_owner = false;
|
||||
|
||||
(has_session_policy, sub_policy.is_allowed(&session_policy_args))
|
||||
(has_session_policy, pollster::block_on(sub_policy.is_allowed(&session_policy_args)))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
|
||||
Reference in New Issue
Block a user