Hi All,
I am having an issue with the CAS module and hoping someone can be helpful.

Our system configuration:
Web server Apache/2.2.3 (Red Hat)
MySQL database 5.0.95
PHP 5.3.10
Drupal 6.25
its a Linux machine

Now we have a multisite install with multiple sites are perfectly ok and work with our CAS server. We recently had a power outage, and a couple sites started producing CAS Login Errors. Most of the sites are working just fine with the CAS and theres over 15 working, 1 is giving me an infinite redirect on login.

What I have Tried so far
1) Check tables on all CAS, User, variable, and session tables.
2) Cleared session table for particular multisite
3) tried upgrading from phpCAS 1.2.0 -> 1.2.1 -> 1.3.0 -> 1.3.1 , Well I was hopeful. All other multisites worked, the one site continued to infinite redirect.
4) happens regardless of broswer

Modules and phpCAS are unmodified.

On the other server, I was able to fix the problem by emptying the user table and the cas tables. This site had only 8 users. The site I am trying to fix now, has 175 users with attached pictures, and profiles .

When I am looking through the phpCAS logs,
I see that it is trying to go to http://mysite/cas?destination=user redirecting to the CAS server, coming back to http://mysite/cas?destination=user and then cycling through that. I am attaching the phpCAS information with site information changed to mysite.

The CAS settings on each of the working sites on the multisite are identical to the one infinitely redirecting. As the only method I have seen to fix this is not viable, I am hoping someone on Drupal has a suggestion. If I have to I will dive into the code, although I have seen this issue pop up enough on drupal.org that I hope someone has a decent solution.

CommentFileSizeAuthor
#12 cas.txt11.78 KBjoshmmo
#10 cas-debug.txt47.3 KBSang33ta
cas.snapshot.txt105.74 KBtomseeber

Comments

bfroehle’s picture

It seems that phpCAS is able to successfully validate the ticket with your CAS server. It then attempts to store the user's identity in $_SESSION['phpcas'] and redirect back to the same URL (but without the ticket=...) parameter. However something along the way gets lost and phpCAS forgets that the user has been authenticated.

I'd guess that your PHP sessions are broken. You can try out an example script in the phpCAS directory (docs/examples/example_simple.php) to try to isolate the problem.

tomseeber’s picture

I can try that, but the other sites ( on the same server), using the same PHP session code are working, and I have working examples of a direct PHP CAS use that is working with the same library outside of Drupal. So I have working examples of the CAS working with Drupal on same server and same code base .... and directly working from php non-drupal code on the same machine. The example_simple.php is very similar to what I used to program the outside of drupal CAS application, are there more debugging functions in the example-simple.php that might give me more info?

metzlerd’s picture

My reading is that points even stronger to some kind of session corruption in the drupal instance. You might try manually deleting all rows from the session table in drupal. DELETE FROM sessions in database that is exhibiting the problem.

metzlerd’s picture

Also given the power failure on this one, you my try mysql database check/repair... you may be having problems with a corrupt data file.

tomseeber’s picture

Hi Metzlerd,

I did check the tables in the database with an extended check ( they were ok) and deleted all values from the sessions table. This did not seem to fix the problem.

scottdc’s picture

Not to "me too" but I am seeing the exact same behavior with the latest build of CAS, latest build of Drupal 6. No matter what i do I get the same result. This was working just a few days ago and now it's suddenly not and I get this redirect loop until my browser throws "too many redirects".

I am running a single-site install of Drupal, not multi-site. Cleared out the sessions table but am still seeing this issue.

Just ran some tests and am only seeing this behavior with new user accounts. My existing older accounts all work fine.

jrreid’s picture

We're seeing this too on some of our sites (D5 and D6 seem to be affected, D7 doesn't) with 1.3.1. But even sites that are affected, only some users are. And weirder, it seems its browser dependent as Chrome doesn't seem to have any issues.

bfroehle’s picture

This is quite disturbing... it'd be good if we could figure out how to reproduce this... any chance we can get a cas debug log from one of these sites? Are any of them running pressflow?

metzlerd’s picture

I don't know if this the only issue here, but I did find a way to reproduce an infinite redirect with these versions of CAS. Basic steps are:

1. Enable creation of user accounts on login
2. Put the site in Maintenance mode
3. Log in with a user that doesn't have the ability access the site in maintenance mode or a new user that does't have a cas login.

Looks like at minimum we have some work to do around maintenance mode checking.

Sang33ta’s picture

StatusFileSize
new47.3 KB

Is there an update on this issue?

We have been facing the same issue on our sites.

Our configuration:

PHP 5.3.3
phpCAS 1.3.1
MySQL database 5.0.77
Drupal 6.26
Web server Apache/2.2.3 (Red Hat)

What we tried:

1. Checked the database for corruptions
2. Cleared the session table
3. Ran the example script provided in phpCAS directory (docs/examples/example_simple.php) . It was successful.

I am seeing the same redirection issue from our phpCAS.log. It is trying to go to http://mysite/cas/login?destination=user which redirects to the CAS server and it comes back to http://mysite/cas/login?destination=user.

I am attaching the phpCAS cas-debug.log information with site information changed to testsite.

bfroehle’s picture

Hmm. The relevant part of your debug log shows that phpCAS is able to successfully authenticate the user, attempts to store the username in $_SESSION, and redirects back to the same page (but w/o the ticket=... parameter). At this point phpCAS develops amnesia and starts all over again. :(

I'm not sure how to debug this remotely.

joshmmo’s picture

StatusFileSize
new11.78 KB

I am also having this same issue. I am running Drupal 7 with cas 1.3.1

I am using a custom theme. I have attached my log as well.

I have noticed sometimes after I try and login with CAS the URL will redirect me back to http://cas.********.com/login?service=https%3A%2F%2Fmysite%2F%3Fq%3Dkb%2...'

and I can delete the first part: "http://cas.********.com/login?service=" and it will take me to the right page and I get authenticated.

Most of the time I get:
"This webpage has a redirect loop
The webpage at https://mysite/?q=kb has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer."

joshmmo’s picture

For those running into this same issue with Drupal 7, you can edit the cas.module file and find this function:

function cas_login_destination() {
  $destination = user_login_destination();
  if ($destination['destination'] == 'cas') {
    $destination['destination'] = '';
  }
  return $destination;
}

and replace it with this

function cas_login_destination() {
	// Equivalent to user_login_destination(), which appeared first in Drupal 6.19.
	$destination = drupal_get_destination();
	$destination = ($destination == 'destination=user/login'); //? 'destination=node' : $destination;

	return $destination == 'destination=cas'; //? 'destination=' : $destination;
}

I have not gotten into it to see exactly why it is breaking but it seems to fix the issue of the never ending redirect. Keep in mind I am sure there is a better solution than just replacing this code, but it is a place to start.

yalet’s picture

I am aware that this is an old issue, but I ran into this problem as well. It seems that CAS does not play well with the

$conf['https'] = TRUE;

option ( mixed session handling: see https://drupal.org/https-information ). Removing that setting (which removes the ability to have http/https shared sessions) solved the problem for me.

bkosborne’s picture

Status: Active » Closed (outdated)

The D6 module won't be seeing any further development as I don't have any time to spend on this, and this issue is quite old. I'm going to close as outdated.