Skip to content

Commit 44d967d

Browse files
committed
Fix signing for requests with the soap binding
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 937c866 commit 44d967d

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/saml2/client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def prepare_for_negotiated_authenticate(
152152
# XXX ^through self.create_authn_request(...)
153153
# XXX - sign_redirect will add the signature to the query params
154154
# XXX ^through self.apply_binding(...)
155-
sign_post = False if binding == BINDING_HTTP_REDIRECT else sign
156-
sign_redirect = False if binding == BINDING_HTTP_POST and sign else sign
155+
sign_redirect = sign and binding == BINDING_HTTP_REDIRECT
156+
sign_post = sign and not sign_redirect
157157

158158
reqid, request = self.create_authn_request(
159159
destination=destination,
@@ -318,10 +318,8 @@ def do_logout(
318318
session_indexes = None
319319

320320
sign = sign if sign is not None else self.logout_requests_signed
321-
sign_post = sign and (
322-
binding == BINDING_HTTP_POST or binding == BINDING_SOAP
323-
)
324321
sign_redirect = sign and binding == BINDING_HTTP_REDIRECT
322+
sign_post = sign and not sign_redirect
325323

326324
log_report = {
327325
"message": "Invoking SLO on entity",

src/saml2/request.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from saml2 import time_util
44
from saml2 import BINDING_HTTP_REDIRECT
5-
from saml2 import BINDING_HTTP_POST
65
from saml2.attribute_converter import to_local
76
from saml2.s_utils import OtherError
87

@@ -55,22 +54,22 @@ def _loads(
5554
logger.debug("xmlstr: %s, relay_state: %s, sigalg: %s, signature: %s",
5655
self.xmlstr, relay_state, sigalg, signature)
5756

58-
signed_post = must and binding == BINDING_HTTP_POST
59-
signed_redirect = must and binding == BINDING_HTTP_REDIRECT
57+
sign_redirect = must and binding == BINDING_HTTP_REDIRECT
58+
sign_post = must and not sign_redirect
6059
incorrectly_signed = IncorrectlySigned("Request was not signed correctly")
6160

6261
try:
6362
self.message = self.signature_check(
6463
xmldata,
6564
origdoc=origdoc,
66-
must=signed_post,
65+
must=sign_post,
6766
only_valid_cert=only_valid_cert,
6867
)
6968
except Exception as e:
7069
self.message = None
7170
raise incorrectly_signed from e
7271

73-
if signed_redirect:
72+
if sign_redirect:
7473
if sigalg is None or signature is None:
7574
raise incorrectly_signed
7675

0 commit comments

Comments
 (0)