Overview

When building a dynamic login link that uses the current page path in the following format /caslogin?returnto=<CURRENT-PAGE-PATH>, the first login will return you to the proper page, but if you log out, go to another page, and log back in, you will not be returned to the correct page. Instead, you will be returned to the page that your first login returned you to. Clearing the cache will resolve the problem for one iteration. In short, some caching bug is making the returnto parameters only work successfully for the first login in a cache cycle.

Dynamic Login Twig code

{% if logged_in %}
    <a href="/user/logout">Log Out</a>
  {% else %}
    <a href="/caslogin{% if not is_front %}?returnto={{ path('<current>') }}{% endif %}">Log In</a>
  {% endif %}

Steps leading to bug

  1. clear all site cache
  2. go to /some/page/x
  3. click Log In link, which points to http://<MY-SITE>/caslogin?returnto=/some/page/x
  4. You are successfully logged in and returned to /some/page/x
  5. Click Log Out link, which return you to the home page
  6. go to /some/page/y
  7. click Log In link, which points to http://<MY-SITE>/caslogin?returnto=/some/page/y
  8. You are authenticated, but inaccurately returned to /some/page/x
  9. You can clear all site cache and the first login redirect will return you to the correct page, but subsequent login redirects won't
CommentFileSizeAuthor
#3 2877417.patch4.81 KBbkosborne

Comments

xeM8VfDh created an issue. See original summary.

xem8vfdh’s picture

Issue summary: View changes
bkosborne’s picture

Status: Active » Needs review
StatusFileSize
new4.81 KB

Thanks for the report! Indeed, this is a bug with wrong cache contexts being set on the redirect response to the CAS server. This patch fixes it, and fixes a test to test against this regression.

Status: Needs review » Needs work

The last submitted patch, 3: 2877417.patch, failed testing.

  • bkosborne committed 1bb4822 on 8.x-1.x
    Issue #2877417 by bkosborne, xeM8VfDh, singularo: cache problem with /...

bkosborne’s picture

Status: Needs work » Fixed

Failures are unrelated to this patch. Looks like it's due to something in 8.4 instead. Will look at separately.

xem8vfdh’s picture

Status: Fixed » Active

Thanks @bkosborne! I may have a chance to review this patch today. Do you want me to hold off due to the testing failures you mentioned, or since they don't relate to this patch do you think its safe for me to move forward with review as soon as I can?

bkosborne’s picture

Status: Active » Fixed

The patch was committed and released as part of 8.0-rc1 this past weekend. Try upgrading to that, then testing again. If still an issue, you can re-open.

xem8vfdh’s picture

I will test it, but, as it turns out, this is one of the cache weirdnesses that I've seen disappear after making the fix here: https://www.drupal.org/node/2694895#comment-12084564

xem8vfdh’s picture

Just tested update, and the dynamic login is working as expected, thanks again for the quick fix

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.