mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
fix(export): fix the policy and service account export (#665)
* fix(export): fix the policy export mechanism * fix: correct service account check logic in IamSys
This commit is contained in:
@@ -528,7 +528,7 @@ impl<T: Store> IamSys<T> {
|
||||
return Err(IamError::NoSuchServiceAccount(access_key.to_string()));
|
||||
};
|
||||
|
||||
if u.credentials.is_service_account() {
|
||||
if !u.credentials.is_service_account() {
|
||||
return Err(IamError::NoSuchServiceAccount(access_key.to_string()));
|
||||
}
|
||||
|
||||
|
||||
@@ -154,8 +154,8 @@ impl Validator for Policy {
|
||||
type Error = Error;
|
||||
|
||||
fn is_valid(&self) -> Result<()> {
|
||||
if !self.id.is_empty() && !self.id.eq(DEFAULT_VERSION) {
|
||||
return Err(IamError::InvalidVersion(self.id.0.clone()).into());
|
||||
if !self.version.is_empty() && !self.version.eq(DEFAULT_VERSION) {
|
||||
return Err(IamError::InvalidVersion(self.version.clone()).into());
|
||||
}
|
||||
|
||||
for statement in self.statements.iter() {
|
||||
@@ -213,8 +213,8 @@ impl Validator for BucketPolicy {
|
||||
type Error = Error;
|
||||
|
||||
fn is_valid(&self) -> Result<()> {
|
||||
if !self.id.is_empty() && !self.id.eq(DEFAULT_VERSION) {
|
||||
return Err(IamError::InvalidVersion(self.id.0.clone()).into());
|
||||
if !self.version.is_empty() && !self.version.eq(DEFAULT_VERSION) {
|
||||
return Err(IamError::InvalidVersion(self.version.clone()).into());
|
||||
}
|
||||
|
||||
for statement in self.statements.iter() {
|
||||
|
||||
@@ -675,7 +675,7 @@ impl Operation for ImportIam {
|
||||
let policies: HashMap<String, rustfs_policy::policy::Policy> = serde_json::from_slice(&file_content)
|
||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, e.to_string()))?;
|
||||
for (name, policy) in policies {
|
||||
if policy.id.is_empty() {
|
||||
if policy.is_empty() {
|
||||
let res = iam_store.delete_policy(&name, true).await;
|
||||
removed.policies.push(name.clone());
|
||||
if let Err(e) = res {
|
||||
|
||||
Reference in New Issue
Block a user