Heres a patch against 7.x-1.x-dev to update the CAS module with some features that are now available or have been removed from the 1.2.x branch of phpCAS. Specifically there is now a supported database storage option for Proxy Granting Tickets as of 1.2.1RC1, and removing the option for storing Proxy Granting Tickets on the File System in XML which was removed in 1.2.2RC1. See https://source.jasig.org/cas-clients/phpcas/trunk/docs/ChangeLog.

The rationale for adding the database support (for those who care) is in our environment we have multiple web servers acting as a cluster of sorts, but they are not sharing any file systems (we use csync2 to keep the code bases in sync) with a single database server. Using the file system method the PGT-IOU is written to the /tmp directory. This means that if a client hits webserver1 but when the CAS server sends its connection to the site and hits webserver2 the PGT-IOU file isn't there, which cases authentication to fail. By storing it in the database it doesn't matter which server either request hits, as the PGT-IOU can be found.

There is still one todo in this patch which I so far haven't been able to figure out. Currently we're assembling a new PDO object to pass to phpCAS by global'ing $databases and digging out the various values in it to build a new PDO instance. The core DatabaseConnection class extends PDO but due to changes in the sub-classes for MySQL and Postgres passing the active database connection from Database::getConnection('default') doesn't work (the script dies on the execute() call in the write function in PGTStorage/Db.php). So anyone with ideas on this I'd love to hear them as this is a bit hacky at the moment.

CommentFileSizeAuthor
cas-pgt-database-7.x-1.x-dev.patch4.08 KBjrreid

Comments

bfroehle’s picture

+++ cas.module	(working copy)
@@ -240,10 +240,25 @@
+      // @todo: Figure out how to use the drupal database connection (which is PDO) instead
+      //$pdo = Database::getConnection();
+
+      // Get drupal DB string
+      global $databases;
+
+      $dsn = 'mysql:host='.$databases['default']['default']['host'].';dbname='.$databases['default']['default']['database'];
+      $pdo = new PDO($dsn, $databases['default']['default']['username'], $databases['default']['default']['password']);
+

I'll consider this for inclusion as soon as we figure out how to get around this...

Do we need to file an issue with Drupal core?

Otherwise maybe we can use Database::getConnectionInfo()?

bfroehle’s picture

Status: Needs work » Closed (won't fix)

In #1827482, we chose to just force the that the format is 'plain'... I'm going to close this as "won't fix".