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(Relay State): Use relay state param for redirection after login #118

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ Contributors
- `Ryan Mahaffey <https://github.com/mahaffey>`_
- `ayr-ton <https://github.com/ayr-ton>`_
_ `kevPo <https://github.com/kevPo>`_
_ `Akshit Dhar <https://github.com/akshit-wwstay>` _
4 changes: 3 additions & 1 deletion django_saml2_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ def acs(r):
saml_client = _get_saml_client(get_current_domain(r))
resp = r.POST.get('SAMLResponse', None)
next_url = r.session.get('login_next_url', _default_next_url())
# If relayState params is passed, use that else consider the previous 'next_url'
next_url = r.POST.get('RelayState', next_url)

if not resp:
return HttpResponseRedirect(get_reverse([denied, 'denied', 'django_saml2_auth:denied']))
Expand Down Expand Up @@ -247,7 +249,7 @@ def signin(r):
r.session['login_next_url'] = next_url

saml_client = _get_saml_client(get_current_domain(r))
_, info = saml_client.prepare_for_authenticate()
_, info = saml_client.prepare_for_authenticate(relay_state=next_url)

redirect_url = None

Expand Down