Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prep_for_nego_auth: avoid double signing redirect requests #973

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vladimir-mencl-eresearch
Copy link
Contributor

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 with True and False.

Python evalutes None and <any value> as None, so as a result, None gets passed for both 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.

Description

The feature or problem addressed by this PR

Fix double signing of of Authentication requests with redirect binding.

What your changes do and why you chose this solution

Fix logic to avoid passing None for both sign_post and sign_redirect (as they both get interpreted as "sign if should_sign)

Checklist

  • Checked that no other issues or pull requests exist for the same issue/change
  • Added tests covering the new functionality
  • Updated documentation OR the change is too minor to be documented
  • Updated CHANGELOG.md OR changes are insignificant

Fixes IdentityPython#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 IdentityPython#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.
@vladimir-mencl-eresearch
Copy link
Contributor Author

Hi @c00kiemon5ter ,

I ran into the issue with double-signed authentication requests ( #819 ) again (even though it was fixed for SATOSA in IdentityPython/SATOSA#380) - and traced it to tri-state logic (None, True, False) passing None for both sign_post and sign_resolve, even though only one should be "sign if we should sign" and the other should be explicit False.

I see the current code was introduced in 44d967d - I believe the logic I put in is correct, but please let me know if you think it was reintroduce the issue that 44d967d (in #834) was solving. (Sorry, I could not deduce the real intent of the change there).

Please let me know if this is OK to merge or if you'd like me to make any changes.

Cheers,
Vlad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AuthnRequest sent via HTTP-Redirect is signed twice (embedded and detached)
1 participant