Skip to content

Commit 994296d

Browse files
fix: prep_for_nego_auth: avoid double signing redirect requests
Fixes #819 (again) The prepare_for_negotiated_authenticate method has sign parameter defaulting to None. The logic setting sign_redirect and sign_post does not properly handle the three-state aspects that sign has with None mixed True and False. Python evalutes `None and <any value>` as None, so as a result, None gets passed forboth sign_redirect and sign_post. However, None is interpreted by Entity._message as "sign if self.should_sign". As a result, for Redirect binding, the authentication request gets signed both in XML and in HTTP parameter (recurrence of #819). Fix this by passing an explicit False for exactly one of the branches (sign_post for REDIRECT binding and sign_redirect for all other bindings), passing through value of `sign` for the other branch.
1 parent 0252ec9 commit 994296d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/saml2/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ def prepare_for_negotiated_authenticate(
144144
# XXX ^through self.create_authn_request(...)
145145
# XXX - sign_redirect will add the signature to the query params
146146
# XXX ^through self.apply_binding(...)
147-
sign_redirect = sign and binding == BINDING_HTTP_REDIRECT
148-
sign_post = sign and not sign_redirect
147+
sign_redirect = sign if binding == BINDING_HTTP_REDIRECT else False
148+
sign_post = sign if binding != BINDING_HTTP_REDIRECT else False
149149

150150
reqid, request = self.create_authn_request(
151151
destination=destination,

0 commit comments

Comments
 (0)