Redirect user on logout : doesn't work

qphrenqp - November 19, 2007 - 10:58
Project:CAS
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:metzlerd
Status:needs review
Description

The error is just the use of a bad parameter name. url is described in the protocol page af CAS http://www.ja-sig.org/products/cas/overview/protocol/index.html and service is used by the CAS module.
Here is just the patch that solves this. I'm not sure about the patch format, though, so i just copy it, if someone wants to validate it...

520c520
<     $logout_destination .= '?service=' . variable_get('cas_logout_destination','');
---
>     $logout_destination .= '?url=' . variable_get('cas_logout_destination','');

#1

irstudio - March 11, 2008 - 20:40
Status:patch (to be ported)» postponed (maintainer needs more info)

do we need an option to choose 'service' vs 'url'?
'service' works fine for me, while 'url' does not

#2

redndahead - May 2, 2008 - 21:43

Url is wrong also. It should be destination. Here is the patch to apply to HEAD

AttachmentSize
destination_url.patch 802 bytes

#3

redndahead - May 2, 2008 - 21:46

Now that I think of it maybe it's a difference between cas 1.0 and cas 2.0. I am using cas 2 and I use destination.

#4

redndahead - May 2, 2008 - 21:47
Status:postponed (maintainer needs more info)» needs review

#5

redndahead - June 16, 2008 - 21:46
Version:5.x-2.2» HEAD

The attached patch was against head so I'm changing the version to head. Dave, any time to look at getting these patches applied to head?

#6

metzlerd - June 24, 2008 - 19:27

url is what works for me as well. Not sure how to proceed. Perhaps we need to rethink this whole thing?

Dave

#7

metzlerd - June 24, 2008 - 19:44

Here's a revised patch that combines an ugly hack do deal with the differences with a strategy submitted under a different issue that also allows for a supplied destination= logout url. Thoughts on this approach?

AttachmentSize
logout.patch 1.75 KB

#8

redndahead - June 25, 2008 - 05:47

It feels like your screaming "YOU WILL REDIRECT IF YOU LIKE IT OR NOT!" ;)

Can you explain the code below more? What are valid entries? I'm confused on how the override actually works.

// Add destination override so that a destination can be specified on the logout link
  // e.g. caslogout?destination=http://foo.bar.com/foobar
  // do not accept caslogout as a valid destination, since that may cause a redirect loop
  $destination = preg_replace("/(destination=|caslogout)/", "", drupal_get_destination());

Attached is a revised patch that fixes some documentation spelling mistakes. The explanation in the settings page should be revised and probably be added to this patch before committing.

AttachmentSize
logout_2.patch 1.75 KB

#9

metzlerd - June 25, 2008 - 14:40

This lets site content providers create different pages put links on their pages like http://example.com/caslogout?destination=http://anothersite.example.com and have their pages redirect to a different url than the one configured.

The code you're talking about just is an extra check to make sure that users cant specifiy destination=caslogout. Which would cause a redirection loop. It just nulls out destination if caslogout is contained in the url.

The normal default destination logic would still apply if denstination= is not specified.

Dave

#10

redndahead - June 26, 2008 - 16:27
Status:needs review» reviewed & tested by the community

Aaaah I think I get it so if on my user page I specifically want a logout tab I can create it and point it to http://example.com/caslogout?destination=node/5 and it will go to that node instead of the global chosen page.

So no documentation is needed on the destination setting.

I would commit as is it looks good. I have tested it and it is working fine for me. Once this is committed I will work on re-rolling my other patches to reflect the updates.

#11

redndahead - June 26, 2008 - 16:34

Is there a reason it is not using the phpCAS logout method?

#12

redndahead - June 26, 2008 - 20:09

FYI I wrote to the phpCAS list about the current logout not supporting destination, url and service. He put it into version 1.0.0RC2. I can now see why you didn't use the phpCAS logout method, because logout wouldn't always work. Once 1.0.0 is released it might be good to only support that version to clean up these nuances.

#13

metzlerd - June 27, 2008 - 18:26

Geat, Am away on vacation, will be back on the 10th at which point I'll commit this.

Dave

#14

metzlerd - July 22, 2008 - 14:53
Assigned to:Anonymous» metzlerd
Status:reviewed & tested by the community» fixed

Committed in Head.

#15

Anonymous (not verified) - August 5, 2008 - 15:03
Status:fixed» closed

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

#16

taroza - October 6, 2009 - 13:52
Status:closed» active

  // Add destination override so that a destination can be specified on the logout link
  // e.g. caslogout?desination=http://foo.bar.com/foobar
  // do not accept caslogout as a valid destination, since that may cause a redirect loop
  $destination = preg_replace("/(destination=|caslogout)/", "", drupal_get_destination());
 
  //Make it an absolute url.  This will also convert <front> to the front page.
  $destination = url($destination, array('absolute' => TRUE));

  // If there was no override and admin has set and enabled a logout destination, look for it
  if (empty($destination) && variable_get('cas_logout_redirect', 0)) {
    $destination = variable_get('cas_logout_destination', '');
    // redirecti is enabled but no url is given - default to baseurl
    if (empty($destination)) {
      $destination = $base_url;
    }
  }

For me redirect to a specific destination does not work. I tried to watchdog before and after the //Make it an absolute url code and the thing is that that when the $destination is empty making it absolute will return the url. Therefore the variable cas_logout_redirect value will never be applied.

Do others have the same issue?

#17

metzlerd - October 6, 2009 - 16:00

Could you post what your settings are. Part of the problem may be that the "Require cas for all pages except" is conflicting with where you send the logout url. Also note the confusion others have had about using the "CAS logout" menu item vs. the normal drupal logout menu item. You need to make sure you're using the CAS provided logout menu item in order for any of this to work.

Dave

#18

taroza - October 6, 2009 - 16:12

The settings are rather ordinary:

  • CAS server is on the localhost
  • "Check to see if the user is logged in" - marked
  • Require CAS login for all pages except specific pages - empty
  • Redirect user on logout - marked
  • Logout destination http://www.google.com

I am using ?q=caslogout to logout.

#19

metzlerd - October 6, 2009 - 17:23

I don't have the same issue but that may be because of drupal revision or configuration differences. If what you say is correct then we ought to patch this by putting an if ($destination) clause in front of the $destination= URL call. Here's the simple patch that would fix that condition.

AttachmentSize
cas-193460.patch 822 bytes

#20

metzlerd - October 6, 2009 - 17:23
Status:active» needs review
 
 

Drupal is a registered trademark of Dries Buytaert.