Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix permission error when deleting user_secret in user_service disable_mfa method #401

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/spaceone/identity/manager/secret_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def get_user_secret_data(self, user_secret_id: str, domain_id: str = None) -> di
def delete_user_secret(self, user_secret_id: str) -> None:
self.secret_conn.dispatch("UserSecret.delete", {"user_secret_id": user_secret_id})

def delete_user_secret_with_system_token(self, domain_id: str, user_secret_id: str) -> None:
system_token = config.get_global("TOKEN")
self.secret_conn.dispatch("UserSecret.delete", {"user_secret_id": user_secret_id}, x_domain_id=domain_id, token=system_token)

def get_user_otp_secret_key(self, user_secret_id: str, domain_id: str = None) -> str:
user_secret_info = self.get_user_secret_data(user_secret_id, domain_id)
return user_secret_info["otp_secret_key"]
2 changes: 1 addition & 1 deletion src/spaceone/identity/service/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def disable_mfa(self, params: UserDisableMFARequest) -> Union[UserResponse, dict
if mfa_type == "OTP":
user_secret_id = user_mfa.get("options", {}).get("user_secret_id")
secret_manager: SecretManager = self.locator.get_manager(SecretManager)
secret_manager.delete_user_secret(user_secret_id)
secret_manager.delete_user_secret_with_system_token(domain_id, user_secret_id)

user_mfa = {"state": "DISABLED"}
self.user_mgr.update_user_by_vo({"mfa": user_mfa}, user_vo)
Expand Down
Loading