Skip to content

Commit e79b0b8

Browse files
authored
feat(sso-app): add default signature method (#787)
* feat(sso-app): add default signature methid * feat(sso-app): add default signature methid
1 parent ff90230 commit e79b0b8

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

descope/auth.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ def exchange_access_key(
251251
) -> dict:
252252
uri = EndpointsV1.exchange_auth_access_key_path
253253
body = {
254-
"loginOptions": {
255-
k: v for k, v in login_options.__dict__.items() if v is not None
256-
}
257-
if login_options
258-
else {},
254+
"loginOptions": (
255+
{k: v for k, v in login_options.__dict__.items() if v is not None}
256+
if login_options
257+
else {}
258+
),
259259
}
260260
server_response = self._http.post(uri, body=body, pswd=access_key)
261261
json_body = server_response.json()

descope/management/sso_application.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def create_saml_application(
7979
default_relay_state: Optional[str] = None,
8080
force_authentication: Optional[bool] = False,
8181
logout_redirect_url: Optional[str] = None,
82+
default_signature_algorithm: Optional[str] = None,
8283
) -> dict:
8384
"""
8485
Create a new SAML sso application with the given name. SSO application IDs are provisioned automatically, but can be provided
@@ -104,6 +105,7 @@ def create_saml_application(
104105
default_relay_state (str): Optional define the default relay state.
105106
force_authentication (bool): Optional determine if the IdP should force the user to re-authenticate.
106107
logout_redirect_url (str): Optional Target URL to which the user will be redirected upon logout completion.
108+
default_signature_algorithm (str): Optional signature algorithm for SAML responses. Use "sha256" to opt in to SHA-256. Leave empty for the default (SHA-1). Only applies to IdP-initiated flows.
107109
108110
Return value (dict):
109111
Return dict in the format
@@ -151,6 +153,7 @@ def create_saml_application(
151153
default_relay_state,
152154
force_authentication,
153155
logout_redirect_url,
156+
default_signature_algorithm,
154157
),
155158
)
156159
return response.json()
@@ -217,6 +220,7 @@ def update_saml_application(
217220
default_relay_state: Optional[str] = None,
218221
force_authentication: Optional[bool] = False,
219222
logout_redirect_url: Optional[str] = None,
223+
default_signature_algorithm: Optional[str] = None,
220224
):
221225
"""
222226
Update an existing SAML sso application with the given parameters. IMPORTANT: All parameters are used as overrides
@@ -242,6 +246,7 @@ def update_saml_application(
242246
default_relay_state (str): Optional define the default relay state.
243247
force_authentication (bool): Optional determine if the IdP should force the user to re-authenticate.
244248
logout_redirect_url (str): Optional Target URL to which the user will be redirected upon logout completion.
249+
default_signature_algorithm (str): Optional signature algorithm for SAML responses. Use "sha256" to opt in to SHA-256. Leave empty for the default (SHA-1). Only applies to IdP-initiated flows.
245250
246251
Raise:
247252
AuthException: raised if update operation fails
@@ -285,6 +290,7 @@ def update_saml_application(
285290
default_relay_state,
286291
force_authentication,
287292
logout_redirect_url,
293+
default_signature_algorithm,
288294
),
289295
)
290296

@@ -390,6 +396,7 @@ def _compose_create_update_saml_body(
390396
default_relay_state: Optional[str] = None,
391397
force_authentication: Optional[bool] = False,
392398
logout_redirect_url: Optional[str] = None,
399+
default_signature_algorithm: Optional[str] = None,
393400
) -> dict:
394401
body: dict[str, Any] = {
395402
"id": id,
@@ -413,6 +420,7 @@ def _compose_create_update_saml_body(
413420
"defaultRelayState": default_relay_state,
414421
"forceAuthentication": force_authentication,
415422
"logoutRedirectUrl": logout_redirect_url,
423+
"defaultSignatureAlgorithm": default_signature_algorithm,
416424
}
417425

418426
return body

tests/management/test_sso_application.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def test_create_saml_application(self):
147147
default_relay_state="relayState",
148148
force_authentication=True,
149149
logout_redirect_url="http://dummy.com/logout",
150+
default_signature_algorithm="sha256",
150151
)
151152
self.assertEqual(resp["id"], "app1")
152153
mock_post.assert_called_with(
@@ -187,6 +188,7 @@ def test_create_saml_application(self):
187188
"defaultRelayState": "relayState",
188189
"forceAuthentication": True,
189190
"logoutRedirectUrl": "http://dummy.com/logout",
191+
"defaultSignatureAlgorithm": "sha256",
190192
},
191193
allow_redirects=False,
192194
verify=True,
@@ -351,6 +353,7 @@ def test_update_saml_application(self):
351353
"defaultRelayState": None,
352354
"forceAuthentication": False,
353355
"logoutRedirectUrl": None,
356+
"defaultSignatureAlgorithm": None,
354357
},
355358
allow_redirects=False,
356359
verify=True,

0 commit comments

Comments
 (0)