Skip to content

Commit 2039053

Browse files
ruvenzxdorsha
andauthored
fix: add enforcessolist and appids to tenant create and update (#734)
Co-authored-by: Doron Sharon <dorsha@descope.com>
1 parent 262ad0f commit 2039053

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

descope/management/tenant.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def create(
1717
self_provisioning_domains: Optional[List[str]] = None,
1818
custom_attributes: Optional[dict] = None,
1919
enforce_sso: Optional[bool] = False,
20+
enforce_sso_exclusions: Optional[List[str]] = None,
21+
federated_app_ids: Optional[List[str]] = None,
2022
disabled: Optional[bool] = False,
2123
) -> dict:
2224
"""
@@ -30,6 +32,8 @@ def create(
3032
Users authenticating from these domains will be associated with this tenant.
3133
custom_attributes (dict): Optional, set the different custom attributes values of the keys that were previously configured in Descope console app
3234
enforce_sso (bool): Optional, login to the tenant is possible only using the configured sso
35+
enforce_sso_exclusions (List[str]): Optional, list of user IDs excluded from SSO enforcement
36+
federated_app_ids (List[str]): Optional, list of federated application IDs
3337
disabled (bool): Optional, login to the tenant will be disabled
3438
3539
Return value (dict):
@@ -51,6 +55,8 @@ def create(
5155
self_provisioning_domains,
5256
custom_attributes,
5357
enforce_sso,
58+
enforce_sso_exclusions,
59+
federated_app_ids,
5460
disabled,
5561
),
5662
)
@@ -63,6 +69,8 @@ def update(
6369
self_provisioning_domains: Optional[List[str]] = None,
6470
custom_attributes: Optional[dict] = None,
6571
enforce_sso: Optional[bool] = False,
72+
enforce_sso_exclusions: Optional[List[str]] = None,
73+
federated_app_ids: Optional[List[str]] = None,
6674
disabled: Optional[bool] = False,
6775
):
6876
"""
@@ -76,6 +84,8 @@ def update(
7684
Users authenticating from these domains will be associated with this tenant.
7785
custom_attributes (dict): Optional, set the different custom attributes values of the keys that were previously configured in Descope console app
7886
enforce_sso (bool): Optional, login to the tenant is possible only using the configured sso
87+
enforce_sso_exclusions (List[str]): Optional, list of user IDs excluded from SSO enforcement
88+
federated_app_ids (List[str]): Optional, list of federated application IDs
7989
disabled (bool): Optional, login to the tenant will be disabled
8090
8191
Raise:
@@ -93,6 +103,8 @@ def update(
93103
self_provisioning_domains,
94104
custom_attributes,
95105
enforce_sso,
106+
enforce_sso_exclusions,
107+
federated_app_ids,
96108
disabled,
97109
),
98110
)
@@ -115,6 +127,9 @@ def update_settings(
115127
inactivity_time_unit: Optional[SessionExpirationUnit] = None,
116128
JITDisabled: Optional[bool] = None,
117129
sso_setup_suite_settings: Optional[SSOSetupSuiteSettings] = None,
130+
enforce_sso: Optional[bool] = None,
131+
enforce_sso_exclusions: Optional[List[str]] = None,
132+
federated_app_ids: Optional[List[str]] = None,
118133
):
119134
"""
120135
Update an existing tenant's session settings.
@@ -136,6 +151,9 @@ def update_settings(
136151
inactivity_time_unit (Optional[SessionExpirationUnit]): Unit for inactivity timeout.
137152
JITDisabled (Optional[bool]): Whether JIT is disabled.
138153
sso_setup_suite_settings (Optional[SSOSetupSuiteSettings]): SSO Setup Suite configuration.
154+
enforce_sso (Optional[bool]): Whether to enforce SSO for the tenant.
155+
enforce_sso_exclusions (Optional[List[str]]): List of user IDs excluded from SSO enforcement.
156+
federated_app_ids (Optional[List[str]]): List of federated application IDs.
139157
140158
Raise:
141159
AuthException: raised if update operation fails
@@ -159,6 +177,9 @@ def update_settings(
159177
"ssoSetupSuiteSettings": (
160178
sso_setup_suite_settings.to_dict() if sso_setup_suite_settings else None
161179
),
180+
"enforceSSO": enforce_sso,
181+
"enforceSSOExclusions": enforce_sso_exclusions,
182+
"federatedAppIds": federated_app_ids,
162183
}
163184

164185
body = {k: v for k, v in body.items() if v is not None}
@@ -298,6 +319,8 @@ def _compose_create_update_body(
298319
self_provisioning_domains: List[str],
299320
custom_attributes: Optional[dict] = None,
300321
enforce_sso: Optional[bool] = False,
322+
enforce_sso_exclusions: Optional[List[str]] = None,
323+
federated_app_ids: Optional[List[str]] = None,
301324
disabled: Optional[bool] = False,
302325
) -> dict:
303326
body: dict[str, Any] = {
@@ -309,4 +332,8 @@ def _compose_create_update_body(
309332
}
310333
if custom_attributes is not None:
311334
body["customAttributes"] = custom_attributes
335+
if enforce_sso_exclusions is not None:
336+
body["enforceSSOExclusions"] = enforce_sso_exclusions
337+
if federated_app_ids is not None:
338+
body["federatedAppIds"] = federated_app_ids
312339
return body

tests/management/test_tenant.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def test_create(self):
8585
["domain.com"],
8686
{"k1": "v1"},
8787
enforce_sso=True,
88+
enforce_sso_exclusions=["user1", "user2"],
89+
federated_app_ids=["app1", "app2"],
8890
disabled=True,
8991
)
9092
self.assertEqual(resp["id"], "t1")
@@ -102,6 +104,8 @@ def test_create(self):
102104
"selfProvisioningDomains": ["domain.com"],
103105
"customAttributes": {"k1": "v1"},
104106
"enforceSSO": True,
107+
"enforceSSOExclusions": ["user1", "user2"],
108+
"federatedAppIds": ["app1", "app2"],
105109
"disabled": True,
106110
},
107111
allow_redirects=False,
@@ -165,6 +169,8 @@ def test_update(self):
165169
["domain.com"],
166170
{"k1": "v1"},
167171
enforce_sso=True,
172+
enforce_sso_exclusions=["user1", "user2"],
173+
federated_app_ids=["app1", "app2"],
168174
disabled=True,
169175
)
170176
)
@@ -182,6 +188,8 @@ def test_update(self):
182188
"selfProvisioningDomains": ["domain.com"],
183189
"customAttributes": {"k1": "v1"},
184190
"enforceSSO": True,
191+
"enforceSSOExclusions": ["user1", "user2"],
192+
"federatedAppIds": ["app1", "app2"],
185193
"disabled": True,
186194
},
187195
allow_redirects=False,

0 commit comments

Comments
 (0)