From 7da29db39b5cd5a0c1b72ddb5a946ff2b01fab19 Mon Sep 17 00:00:00 2001 From: Mads Freek Petersen <freek@wayf.dk> Date: Sat, 20 Mar 2010 12:17:16 +0000 Subject: [PATCH] Updated the casserver module as per Dubravko Voncinas comments in http://rnd.feide.no/content/simplesamlphp-cas-server-support. cas.php is a frontend for login.php, validate.php and serviceValidate.php. It allows them to be called as cas.php/login, cas.php/validate and cas.php/serviceValidate and is meant for clients like phpCAS which expects one configured prefix to which it appends login, validate and serviceValidate. The apache configurationchanges Dubravko Voncina mention is thus not necessary any longer. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2227 44740490-163a-0410-bde0-09ae8108e29a --- modules/casserver/www/cas.php | 13 +++++++++++++ modules/casserver/www/login.php | 2 +- modules/casserver/www/serviceValidate.php | 2 +- modules/casserver/www/validate.php | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 modules/casserver/www/cas.php diff --git a/modules/casserver/www/cas.php b/modules/casserver/www/cas.php new file mode 100644 index 000000000..180120a1c --- /dev/null +++ b/modules/casserver/www/cas.php @@ -0,0 +1,13 @@ +<?php + +/* + * Frontend for login.php, validate.php and serviceValidate.php. It allows them to be called + * as cas.php/login, cas.php/validate and cas.php/serviceValidate and is meant for clients + * like phpCAS which expects one configured prefix which it appends login, validate and + * serviceValidate to. + */ + + +list($function) = preg_split('/[\/?]/', $_SERVER['PATH_INFO'], 0, PREG_SPLIT_NO_EMPTY); + +include($function.".php"); \ No newline at end of file diff --git a/modules/casserver/www/login.php b/modules/casserver/www/login.php index cfe3a714c..34fd04d5c 100644 --- a/modules/casserver/www/login.php +++ b/modules/casserver/www/login.php @@ -52,7 +52,7 @@ if (!$session->isValid($auth) ) { $attributes = $session->getAttributes(); $path = $casconfig->resolvePath($casconfig->getValue('ticketcache', 'ticketcache')); -$ticket = SimpleSAML_Utilities::generateID(); +$ticket = str_replace( '_', 'ST-', SimpleSAML_Utilities::generateID() ); storeTicket($ticket, $path, $attributes); // $test = retrieveTicket($ticket, $path); diff --git a/modules/casserver/www/serviceValidate.php b/modules/casserver/www/serviceValidate.php index dde96ade3..823f59222 100644 --- a/modules/casserver/www/serviceValidate.php +++ b/modules/casserver/www/serviceValidate.php @@ -91,7 +91,7 @@ function storeTicket($ticket, $path, &$value ) { function retrieveTicket($ticket, $path) { - if (!preg_match('/^_?[a-zA-Z0-9]+$/D', $ticket)) throw new Exception('Invalid characters in ticket'); + if (!preg_match('/^ST-?[a-zA-Z0-9]+$/D', $ticket)) throw new Exception('Invalid characters in ticket'); if (!is_dir($path)) throw new Exception('Directory for CAS Server ticket storage [' . $path . '] does not exists. '); diff --git a/modules/casserver/www/validate.php b/modules/casserver/www/validate.php index 27e847efe..4622e0c2b 100644 --- a/modules/casserver/www/validate.php +++ b/modules/casserver/www/validate.php @@ -72,7 +72,8 @@ function storeTicket($ticket, $path, &$value ) { function retrieveTicket($ticket, $path) { - if (!preg_match('/^_?[a-zA-Z0-9]+$/D', $ticket)) throw new Exception('Invalid characters in ticket'); + if (!preg_match('/^ST-?[a-zA-Z0-9]+$/D', $ticket)) throw new Exception('Invalid characters in ticket'); + if (!is_dir($path)) throw new Exception('Directory for CAS Server ticket storage [' . $path . '] does not exists. '); -- GitLab