Index: cas.module
===================================================================
--- cas.module	(revision 245)
+++ cas.module	(revision 247)
@@ -130,7 +132,17 @@
     $start_session = (boolean)FALSE;
     cas_save_page();
     $cas_service_ticket = $_GET['ticket'];  // We use this later for CAS 3 logoutRequests
-    phpCAS::client($server_version, $server_cas_server, $server_port, $server_uri, $start_session);
+    if ( variable_get("cas_proxy",0) ) {
+      phpCAS::proxy($server_version, $server_cas_server, $server_port, $server_uri, $start_session);
+      $casPGTStoragePath = variable_get("cas_pgtpath","");
+      if ( $casPGTStoragePath != "" ) {
+        $casPGTFormat = variable_get("cas_pgtformat", "plain");
+        phpCAS::setPGTStorageFile($casPGTFormat, $casPGTStoragePath);
+      }
+    }
+    else {
+      phpCAS::client($server_version, $server_cas_server, $server_port, $server_uri, $start_session);
+    }
     // force CAS authentication
     // Determine if CA option is set.  This is only avialable in version 0.6 or greater, so we need to test
     // to make sure its callable.
@@ -417,6 +429,28 @@
     '#size' => 30, '#description' => 'With client version 0.6 or greater this is the certificate for validating cas or the cas CA as appropriate.',
   );
   
+  $form['server']['cas_proxy'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Initialize CAS as proxy'),
+    '#default_value' => variable_get('cas_proxy', 0),
+    '#description' => t('When using a proxy it is required to set the option "Require CAS login for:" to "specific pages" with "node/*" as a specific page or "all pages except specific pages" on the "Redirection settings".')
+  );
+      
+  $form['server']['cas_pgtformat'] = array(
+    '#type' => 'radios',
+    '#title' => t('CAS PGT storage file format'),
+    '#default_value' => variable_get('cas_pgtformat', 'plain'),
+    '#options' => array('plain' => 'Plain Text', 'xml' => 'XML'),
+  );
+      
+  $form['server']['cas_pgtpath'] = array(
+    '#type' => 'textfield',
+    '#title' => t('CAS PGT storage path'),
+    '#default_value' => variable_get('cas_pgtpath', ''),
+    '#size' => 30,
+    '#description' => "Only needed if 'Use CAS proxy initializer' is configured. Leave empty for default.",
+  );
+  
   $form['server']['cas_signout'] = array(
 	'#type' => 'checkbox',
 	'#title' => t('Enable CAS Single Sign Out (CAS server 3.1 or greater)'),
