Maintaining our own logout function is duplicitous. It's also error prone, as in

cas_logout()</a> we call
<code>
$edit = array(); 
user_module_invoke( 'logout', $edit, $user);

which is incorrect. Instead, the call should be

module_invoke_all('user_logout', $user);

(This can be verified by looking at the arguments to hook_user_logout() or by reading through the similar user_logout().

Instead we should implement hook_user_logout(). This would eliminate the need to have two logout links (/logout and /caslogout). The redirection functionality could be maintained through a clever use of hook_drupal_goto_alter(), although I'd advocate depreciating the logout redirection option in the CAS module and instructing users to configure a logout option via the more general trigger.module anyway.

Comments

metzlerd’s picture

Not sure I agree here, but am willing to chat. I use the drupal (vs. cas) logout all the time as a mechanism for testing, and redirecting to cas logout causes you to log completely out of cas and affects all other apps you're signed into.

We could make a setting and it might still go a long way toward simplifying the code, and would also allow for the logging out of CAS to affect all sites, but again it would have to behave differently depending on external vs internal account designation. Lets tackle this when we remove INTERNAL option ok? (It will be much easier to get right).

bfroehle’s picture

Status: Active » Postponed

I agree the Drupal logout vs. CAS logout is great for testing. However, that could be easily solved in other ways (e.g., a devel-type module which just clears your session).

It's been my experience that my users generally expect that clicking 'logout' in a CAS-ified application fully logs them out of CAS. (Explaining the distinction of being logged into a site vs. logged in globally to a CAS server is something that generally goes way over their heads).

I'll add a note in #1011876: CAS users cannot change their password or e-mail address to see this issue as well. Marking as postponed, for now.

bfroehle’s picture

Issue tags: +CAS Wishlist

~

bfroehle’s picture

Title: Depreciate /caslogout in favor of hook_user_logout » Fix hook_user_logout call in D7
Status: Postponed » Needs review
StatusFileSize
new404 bytes

While this issue is postponed until we tackle #1011876: CAS users cannot change their password or e-mail address, we should still fix the issue in the original post, namely the hook_user_logout call is incorrect.

The attached patch fixes cas_logout to mimic user_logout.

metzlerd’s picture

Status: Needs review » Fixed

Agreed straightfoward, committed.

bfroehle’s picture

Title: Fix hook_user_logout call in D7 » Depreciate /caslogout in favor of hook_user_logout
Status: Fixed » Postponed

Setting back to postponed, for future discussion of depreciating /caslogout.

metzlerd’s picture

FYI: There's also the issue that doing this in a user_logout hook, may make other pages not fire correctly, because there is a redirect that needs to happen in order to properly accomplish this. So this tradeoff between doing this this way, and dealing with problems of module weights to make sure other hooks get fired.

I'm also not sure it will work properly because it sets up a module weight confilict of interest. Cas needs to be fired first for login and last for logout, but hooks fire in order of module weight. We can't have the weight being both ways here.

Short is, I'm still unconvinced that changing the way that this behaves is the right thing to do. I always move/hide the logout menu and promote the cas one instead so that I get controlled and predictable behavior.

bfroehle’s picture

Oh interesting... didn't think of the module weight issue. Hmm.

D7 has a lot of hooks which may make this feasible. For example, maybe hook_user_logout sets a SESSION variable marking that we need to redirect to the logout screen. Then hook_drupal_goto_alter() checks for the presence of the SESSION variable and redirects at the last possible minute.

In D6, I don't see a clear way to do it.

Thanks for all your work, as always! :)

bfroehle’s picture

StatusFileSize
new1014 bytes

It wasn't particularly intuitive for me to know to add the special CAS login / CAS logout links on my first installation. Especially since CAS login can work with the basic user login page, leaving you with no mechanism to log out of CAS until you discover the menu items.

This is not the only time this has been suggested, see also:
#144879: Tap into logout op of hook_user
#546322: hook_user for cas logout

CAS logout invokes the logout hook to make sure things that need to be done by other modules on logout happen. If we redirect on hook user logout, wouldn't that potentially make modules that have a higher weight not have their hook_user methods fire on logout. This way we know that the logout has completed prior to doing the redirect, yes?

This is totally true. Another way to accomplish this would be to alter the menu item for 'logout' to be a custom function which handles both CAS and non-CAS users. It could be as simple as the attached patch, or as complicated as an option for the following:

  1. No global CAS logout.
  2. On logout, display a link to the global CAS logout.
  3. Automatically globally logout.

Please note that this issue is still at "postponed" -- I have no desire to fix this before 6.x-3.0 or 7.x-1.0.

bfroehle’s picture

Component: Code » CAS

#732542: system_goto_action breaks core APIs is considering adding 'skip destination' and 'delayed' parameters to drupal_goto, which may make this issue solvable (and would also clean up a lot of our unset($_REQUEST['destination']) code).

bfroehle’s picture

What if instead of removing /caslogout we instead just tweak the behavior of the regular logout to print a message reminding users that they may want to also log out of CAS...e.g., "You have been logged out of Drupal. Log out of CAS."

Then we could keep two parallel tracks:

/caslogout -> full logout, including CAS
/logout -> drupal logout, plus message reminding you to log out of CAS

metzlerd’s picture

Creative! I like it, particularly if we include a link to the cas logout site to facilatate logout.

bfroehle’s picture

Title: Depreciate /caslogout in favor of hook_user_logout » Remind users to log out of CAS after /logout
Category: feature » task
Status: Postponed » Active
Issue tags: -CAS Wishlist

Retitling and changing to as task. No idea if this is even feasible (as caching might get in the way). We'll find out, I guess.

liam morland’s picture

bfroehle’s picture

Category: task » feature

  • Commit 7f4fb3d on 7.x-1.x, 8.x-1.x by metzlerd:
    #1018904 Change mechanism for user_logout call.
    
    
dobie_gillis’s picture

Issue summary: View changes

Is this patch still relevant? I have a problem with CAS v7.x-1.x-dev where a CAS user gets logged out of Drupal, but they're never logged out of CAS. After some reading, it looks like this function handleLogoutRequests() handles CAS logouts (since phpCAS 1.0). Should we be calling this function?

  • metzlerd committed 7f4fb3d on 8.x-1.x-PROXY
    #1018904 Change mechanism for user_logout call.
    
    
damienmckenna’s picture

How about logging out the user account and redirecting the user to the CAS logout path to end their session?

metzlerd’s picture

I'm not quite sure what's being asked here. THis is the behaviour of the current caslogout menu item that you can enable if no logout destination is set.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new434 bytes

How about something like this? If someone loads /user/logout it'll first let Drupal logout the user normally and then bounce the user to the CAS server to log them out.

Status: Needs review » Needs work

The last submitted patch, 21: cas-n1018904-21.patch, failed testing.

bkosborne’s picture

The problem with the approach in #21 is discussed above. Doing so "short circuits" the logout hook because it redirects the user to the CAS server. All other implementations of hook_user_logout would not run, unless they executed first.