Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ can set in the settings.py file::

This setting is True by default.

ACS_DEFAULT_REDIRECT_URL = reverse_lazy('some_url_name')

This setting lets you specify a URL for redirection after a successful
authentication. Particularly useful when you only plan to use
IdP initiated login and the IdP does not have a configured RelayState
parameter. The default is ``/``.

The other thing you will probably want to configure is the mapping of
SAML2 user attributes to Django user attributes. By default only the
User.username attribute is mapped but you can add more attributes or
Expand Down
3 changes: 2 additions & 1 deletion djangosaml2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ def assertion_consumer_service(request,
post_authenticated.send_robust(sender=user, session_info=session_info)

# redirect the user to the view where he came from
relay_state = request.POST.get('RelayState', '/')
default_relay_state = get_custom_setting('ACS_DEFAULT_REDIRECT_URL', '/')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with this, but how about changing the '/' default to settings.LOGIN_REDIRECT_URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. It would be consistent with the lines below.

relay_state = request.POST.get('RelayState', default_relay_state)
if not relay_state:
logger.warning('The RelayState parameter exists but is empty')
relay_state = settings.LOGIN_REDIRECT_URL
Expand Down