This issue is related to one of the comments in simplesamlphp_auth.module:
ISSUE: User is always dropped on user page after login, instead of where they were when they clicked "Federated Log In". Because of this, deep linking to access controlled content does not work. Usability would be considerably increased if this were resolved.
Just to illustrate what I'd like to fix, here are a couple scenarios.
Without this module (just the usual Drupal auth in place), it goes like this:
- User visits a protected page ( /admin )
- Drupal returns the "Access Denied" page, including a link to log in - that link goes to /user/login?destination=admin
- User visits that page, and logs in
- and finally gets redirected back to /admin, which they can now view as an authenticated user
With SimpleSAMLphp Auth active (at least with 7.x-3.x-dev), the process varies starting with step 3:
- User visits a protected page ( /admin )
- Drupal returns the "Access Denied" page, including a link to log in - that link goes to /user/login?destination=admin
- User visits /user/login?destination=admin -- there they still see the usual username and password field, but also a link to login via SAML, which by default is a link to /saml_login labeled "Federated Log In"
- User visits /saml_login, is taken off to the SAML IdP's login process
- and eventually comes back to the Drupal site, and is dropped at /user
There are some existing issues relating to this, but I'm not sure the proposed fixes quite address what I'm trying to accomplish. It looks like there's support for a ReturnTo parameter in 7.x-3.x, but I wasn't sure how to use that.
My proposed fix (inspired by brad.bulger's comment on this other issue) is to modify the /saml_login link that is displayed on the /user/login page to also include the destination query parameter. Continuing with the example of trying to visit /admin:
- user visits /admin, gets "access denied"
- clicks the Log in link, taking them to /user/login?destination=admin
- with this change, that page would link to /saml_login?destination=admin (instead of just /saml_login)
- user clicks that Federated Log In link
- user gets redirected to the SAML IdP, and logs in
- and gets redirected back to /saml_login?destination=admin
- since they've now authenticated, user is finally redirected to /admin
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | preserve-login-destination-2684535-4-7.x-3.x-dev.patch | 713 bytes | larcher |
| #2 | preserve-login-destination-2684535-2-7.x-3.x-dev.patch | 829 bytes | larcher |
Comments
Comment #2
larcher commentedComment #3
snufkin commentedLooks good, thanks for this. Just a couple of standard related comments:
Could you fix the whitespace issue here?
Could you please put the else on a new line according to Drupal coding standards?
Comment #4
larcher commentedThanks for the quick review. I actually just learned about
drupal_get_destination, which would eliminate any direct checking of$_GET['destination']. New patch attached.Comment #5
larcher commentedComment #6
larcher commentedComment #7
snufkin commentedThanks, committed.
Comment #10
nileshnpathade@gmail.com commentedI am facing issue realated saml_login.
I am missing something, I am very new in Drupal. I have drupal site which is using saml login.
When I called www.mydomainname.com/user/login then it's automatically called www.mydomainname/saml_login and showing white page..
even I can't login with admin as well.
Please assist me.
Regard
Nil