Skip to content

Commit 141a807

Browse files
committed
set different manage security groups based on user type
1 parent f455893 commit 141a807

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/mas/devops/users.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ def link_user_to_local_idp(self, user_id, email_password=False):
326326
if response.status_code != 200:
327327
raise Exception(response.text)
328328

329+
# Important: HTTP 200 output will contain generated user token; DO NOT LOG
330+
329331
return None
330332

331333
def get_user(self, user_id):
@@ -645,15 +647,12 @@ def get_manage_group_id(self, group_name):
645647
"Accept": "application/json",
646648
"apikey": self.manage_maxadmin_api_key["apikey"], # <--- careful, don't log headers as-is (apikey is sensitive)
647649
}
648-
self.logger.debug(f" > {url} {querystring}")
649-
650650
response = requests.get(
651651
url,
652652
headers=headers,
653653
params=querystring,
654654
verify=self.manage_internal_ca_pem_file_path,
655655
)
656-
self.logger.debug(f" < {response.status_code}")
657656
if response.status_code != 200:
658657
raise Exception(response.text)
659658

@@ -885,6 +884,8 @@ def create_initial_user_for_saas(self, user, user_type):
885884
}
886885
is_workspace_admin = True
887886
application_role = "ADMINISTRATOR"
887+
# TODO: check which security groups primary users should be members of
888+
manage_security_groups = ["MAXADMIN"]
888889
elif user_type == "SECONDARY":
889890
permissions = {
890891
"systemAdmin": False,
@@ -898,6 +899,8 @@ def create_initial_user_for_saas(self, user, user_type):
898899
}
899900
is_workspace_admin = False
900901
application_role = "USER"
902+
# TODO: check which security groups secondary users should be members of
903+
manage_security_groups = []
901904
else:
902905
raise Exception(f"Unsupported user_type: {user_type}")
903906

@@ -930,13 +933,16 @@ def create_initial_user_for_saas(self, user, user_type):
930933
for mas_application_id in mas_application_ids:
931934
self.await_mas_application_availability(mas_application_id)
932935
if mas_application_id == "manage":
936+
# special case for manage; role is always "MANAGEUSER"
933937
role = "MANAGEUSER"
934938
else:
939+
# otherwise grant the user the appropriate role for their user_type
935940
role = application_role
936941
self.set_user_application_permission(user_id, mas_application_id, role)
937942

938943
for mas_application_id in mas_application_ids:
939944
self.check_user_sync(user_id, mas_application_id)
940945

941946
if "manage" in mas_application_ids:
942-
self.add_user_to_manage_group(user_id, "MAXADMIN")
947+
for manage_security_group in manage_security_groups:
948+
self.add_user_to_manage_group(user_id, manage_security_group)

0 commit comments

Comments
 (0)