Actualy in cas_logout() there is a drupal_goto() at the end. Why don't use phpCAS::logoutWithRedirectService($base_url) instead of a drupal_goto()? In that case the user can be redirect automaticaly to drupal site after logout on cas server (if cas server as logout redirects enabled).

P.S.: To enable logout redirect on cas server you should add in the file cas-servlet.xml the property p:followServiceRedirects="true" on logoutController

Comments

bfroehle’s picture

That sounds okay to me. Patches are welcome.

mecmartini’s picture

Great! I will post a patch soon.

mecmartini’s picture

StatusFileSize
new1.5 KB

Here there is the patch!

Basicaly it use the method logoutWithRedirectService() of phpCAS to do the logout on CAS and redirect back.

Remember that to enable logout redirect on cas server you should add in the file cas-servlet.xml the property p:followServiceRedirects="true" on logoutController section. Otherwise it will only logout without redirect and it will remain on cas logout page.

Hope it's ok ;)

bfroehle’s picture

Hmm, I didn't notice the $base_url in your original post. So this issue is about two things:

  1. Using phpCAS::logout...() instead of drupal_goto()
  2. Using a different default logout destination.
mecmartini’s picture

Yes originaly I was using $base_url to test it, then I adapted the patch with the same criteria already used on cas module based on $destination_url. Look at the patch to understand ;)

bfroehle’s picture

Okay, let's drop the $base_url part. If you want to redirect back to the main page, you should enter <front> as the redirection destination. If that's not clear from the config page we should clarify the help.

mecmartini’s picture

StatusFileSize
new1.41 KB

OK I'm agree.

Here is the new patch without $base_url.

bfroehle’s picture

Status: Active » Needs work
+++ cas.module	2012-03-07 17:37:51.000000000 +0100
@@ -685,9 +679,8 @@ function cas_logout($invoke_hook = TRUE)
+  // Logout on cas server and redirect to drupal if logout redirects is enabled on cas server.
+  phpCAS::logoutWithRedirectService($destination_url);

What if $destination_url is now empty? Does phpCAS::logoutWithRedirectService('') work? Or do we need to do something instead like:

if (!empty($destination_url)) {
  phpCAS::logoutWithRedirectService($destination_url);
}
else {
  phpCAS::logout();
}

Thanks for the testing!

mecmartini’s picture

It work as phpCAS::logout(), so we don't need to check if it's empty.

bfroehle’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, cas_logout.patch, failed testing.

mecmartini’s picture

StatusFileSize
new1.41 KB

Sorry I made the patch without git.

Let's look if this one is ok.

mecmartini’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, cas_module.diff, failed testing.

mecmartini’s picture

Status: Needs work » Needs review
StatusFileSize
new1.41 KB

Status: Needs review » Needs work

The last submitted patch, cas-logout-with-service-1470574-15.patch, failed testing.

mecmartini’s picture

I can't understand why pathc fail the test! Can somebody help me?

Otherwise I'll post the patched file and you will make the patch?

metzlerd’s picture

I can't speak to all the issues, but some are due to the fact that in not all cases do you garantee that $destination_url is set. So you get an undefined notice error in that case. Did you look the view details on the test link above? Remember that the code needs to work if no destination logout url is set as well.

mecmartini’s picture

Status: Needs work » Needs review
StatusFileSize
new1.57 KB

Ok let's try if this one can fix the $destination_url error.

#metzlerd
Remember that the code needs to work if no destination logout url is set as well.

Of course it work ;)

Status: Needs review » Needs work

The last submitted patch, cas-logout-with-service-1470574-19.patch, failed testing.

bfroehle’s picture

Title: cas_logout() redirect » Use phpCAS methods for CAS logout.
Status: Needs work » Needs review
StatusFileSize
new1.68 KB

Revised patch attached.

Status: Needs review » Needs work

The last submitted patch, 1470574-cas-logout-7-21.patch, failed testing.

bfroehle’s picture

Status: Needs work » Needs review
StatusFileSize
new1.64 KB

Ahh, I see. The CAS tests expected logoutWithUrl, but the patch was using logoutWithRedirectService. I think we should maintain both flavors so as not change the functionality.

mecmartini’s picture

Great! Finally it passed the test :)

Thank's for the support, I'm happy to know that my patch was useful ;)

bfroehle’s picture

If you want to test it manually and report back with success, I'll go ahead and commit this. :)

mecmartini’s picture

Ok I will tomorrow. Now it's time to sleep form me!

mecmartini’s picture

StatusFileSize
new1.65 KB

Well I tested it, and it doesn't work.

The problem is on the line
phpCAS::logoutWithRedirectService($options);

I changed it with
phpCAS::logoutWithRedirectService($destination_url);

I attach a new patch let's see if works!

Status: Needs review » Needs work

The last submitted patch, 1470574-cas-logout-7-27.patch, failed testing.

mecmartini’s picture

Status: Needs work » Needs review
StatusFileSize
new37.97 KB
mecmartini’s picture

StatusFileSize
new1.06 KB

Sorry I made a wrong patch in the previous post. My mistake!

Status: Needs review » Needs work

The last submitted patch, 1470574-cas-logout-7-30.patch, failed testing.

mecmartini’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

Status: Needs review » Needs work

The last submitted patch, 1470574-cas-logout-7-32.patch, failed testing.

mecmartini’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

Status: Needs review » Needs work

The last submitted patch, 1470574-cas-logout-7-34.patch, failed testing.

mecmartini’s picture

Status: Needs work » Needs review

So the problem is that phpCAS::logoutWithRedirectService() need a string as paramater and if we do it the code works but the test fail. If we pass as parameter the array $options the code doesn't work.

What to do?

mecmartini’s picture

StatusFileSize
new1.1 KB

I changed the method phpCAS::logoutWithRedirectService() with phpCAS::logout() that need an array as parameter.

Status: Needs review » Needs work

The last submitted patch, 1470574-cas-logout-7-37.patch, failed testing.

bfroehle’s picture

Can you try the patch I suggested in post #23? It does use phpCAS::logout() (and not phpCAS::logoutWithRedirectService()).

mecmartini’s picture

Sorry I made a mistake! The patch #23 works.

I thought it did not work because appling it I leaved phpCAS::logoutWithRedirectService() instead of phpCAS::logout().

So at the end it seems works weel :)

bfroehle’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.67 KB

Testing a backport of this patch to 6.x-3.x.

bfroehle’s picture

Version: 6.x-3.x-dev » 7.x-1.x-dev
Status: Needs review » Fixed

Committed to 6.x-3.x and 7.x-1.x. Thanks for the report and initial patch.

mecmartini’s picture

Great!

Thanks to you for the support :)

Status: Fixed » Closed (fixed)

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

Stanto’s picture

Status: Closed (fixed) » Active

Hi there,
I'm reopening this ticket because I just read the phpCAS class, and we should stick with the original phpCAS::logoutWithRedirectService instead of logoutWithUrl

As you can see:

    public static function logoutWithUrl($url)
    {
        trigger_error('Function deprecated for cas servers >= 3.3.5.1', E_USER_DEPRECATED);
        ...
    }

And all over the place it says :

     * @deprecated The url parameter has been removed from the CAS server as of
     * version 3.3.5.1

What do you think about that?

bfroehle’s picture

Status: Active » Closed (fixed)

@Stanto: I think it's fine because the patch we ended up using calls:

phpCAS::logout(array('service' => ..., 'url => ...));
Stanto’s picture

@bfroehle : Thanks for the quick answer. And as you said the function phpCAS::logout() doesn't say anything about the url parameter being deprecated, but if you look at the function logoutWithUrl($url) (which basically launch phpCAS::logout() ) is deprecated, as well as the $url argument everywhere else (here for example phpCAS::logoutWithRedirectServiceAndUrl()).

Basically this url parameter seems to be annoying with (at least) rubycas-server : https://github.com/rubycas/rubycas-server/issues/86

And as you can see in the CAS specs (http://www.jasig.org/cas/protocol at 2.3.1) the "url" parameter is (was?) used to display a blurb of text like : "The application you just logged out of has provided a link it would like you to follow. Please click [link]here to continue". Its purpose is definitely not to redirect the user to an other page.

I feel that the straightforward approach would be to use phpCAS::logoutWithRedirectService instead of phpCAS::logout, but if you want to keep the url option, what do you think about adding a setting in the admin UI ?

bfroehle’s picture

@Stanto: Historically we've always provided the url and service parameters. And in the past we even sent a destination parameter.

Given that the 'url' option was in the official Jasig CAS protocol not too long ago (and might still be?), I don't think we need to stop sending it. No admin option for this, it's not worth the extra complexity. I'm sorry to hear that rubcas-server can't handle it, but frankly I think the burden lies with them.

Dave, what do you think?

Stanto’s picture

My point is just that sending the "url" parameter at the same time as sending the "service" parameter doesn't really make sense.
On one hand the service parameter defines basically a redirection, while the url parameter define some link to put in the logout page.

The "URL" parameter should not be used for any redirection since that's what "service" is meant for.

I completely agree with you on the fact that the Ruby implementation should handle properly those use cases, but that doesn't change the fact that we're sending wrong values to the CAS server.
And it's pretty confusing.. How does it know if it should display the logout message or redirect?

metzlerd’s picture

The reason that both parameters were added was that different CAS server versions were responding to different parameters. If you had an older version of the cas server it might respond to one vs. the other based on the way the cas server was setup or compiled.

If we picked one at the exclusion of the other, it would work for some sites but not others. How the server handles the parameters is a server implementation decision. Many cas servers are customized and will use the service parameter at login to decide what level of trust. It may or may not allow redirection after logout based on the requesting service at login. In such cases the cas clients would often desire that the link appear on the logout page instead, hence the desire for the url parameter.

The cas protocol specification is full of "should's" vs. "must" which are interpreted differently based on the server implementation. As always, we're just trying to figure out what will work in the 80% use cases. The current handling of this was the result of such a discussion. We switched to service= and took away the url and it broke the cas module for another user, so we elected to send both.

  • Commit 93fc9a8 on 7.x-1.x, 8.x-1.x by bfroehle:
    Issue #1470574 by mecMartini, bfroehle: Use phpCAS routines for CAS...