Skip to content

Commit 1608c3a

Browse files
committed
Reorganize revoke mfa policy to account for arborist lower case username expectation
1 parent 69ad440 commit 1608c3a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

fence/sync/sync_users.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1900,23 +1900,19 @@ def _revoke_all_policies_preserve_mfa(self, username, idp=None):
19001900
If MFA is enabled for the user's idp, check if they have the /multifactor_auth resource and restore the
19011901
mfa_policy after revoking all policies.
19021902
"""
1903-
user_data_from_arborist = None
1904-
try:
1905-
user_data_from_arborist = self.arborist_client.get_user(username)
1906-
except ArboristError:
1907-
# user doesn't exist in Arborist, nothing to revoke
1908-
return
19091903

19101904
is_mfa_enabled = "multifactor_auth_claim_info" in config["OPENID_CONNECT"].get(
19111905
idp, {}
19121906
)
1907+
19131908
if not is_mfa_enabled:
19141909
# TODO This should be a diff, not a revocation of all policies.
19151910
self.arborist_client.revoke_all_policies_for_user(username)
19161911
return
19171912

19181913
policies = []
19191914
try:
1915+
user_data_from_arborist = self.arborist_client.get_user(username)
19201916
policies = user_data_from_arborist["policies"]
19211917
except Exception as e:
19221918
self.logger.error(
@@ -1927,7 +1923,7 @@ def _revoke_all_policies_preserve_mfa(self, username, idp=None):
19271923
self.arborist_client.revoke_all_policies_for_user(username)
19281924

19291925
if "mfa_policy" in policies:
1930-
status_code = self.arborist_client.grant_user_policy(username, "mfa_policy")
1926+
self.arborist_client.grant_user_policy(username, "mfa_policy")
19311927

19321928
def _update_authz_in_arborist(
19331929
self,

0 commit comments

Comments
 (0)