Skip to content
Snippets Groups Projects
Commit 4b3fec9a authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

update phpCAS API usage for phpCAS 1.5.0, fixes #1573

Closes #1573

Merge request studip/studip!1003
parent 642ce811
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
* @category Stud.IP * @category Stud.IP
*/ */
require_once 'composer/jasig/phpcas/CAS.php';
require_once 'lib/classes/cas/CAS_PGTStorage_Cache.php'; require_once 'lib/classes/cas/CAS_PGTStorage_Cache.php';
class CasController extends StudipController class CasController extends StudipController
...@@ -25,7 +24,7 @@ class CasController extends StudipController ...@@ -25,7 +24,7 @@ class CasController extends StudipController
$pgt = Request::get('pgtId'); $pgt = Request::get('pgtId');
$pgt_iou = Request::get('pgtIou'); $pgt_iou = Request::get('pgtIou');
$cas_config = $GLOBALS['STUDIP_AUTH_CONFIG_CAS']; $cas_config = $GLOBALS['STUDIP_AUTH_CONFIG_CAS'];
$cas = new CAS_Client(CAS_VERSION_2_0, true, $cas_config['host'], $cas_config['port'], $cas_config['uri'], false); $cas = phpCAS::proxy(CAS_VERSION_2_0, $cas_config['host'], $cas_config['port'], $cas_config['uri'], false);
$pgt_storage = new CAS_PGTStorage_Cache($cas); $pgt_storage = new CAS_PGTStorage_Cache($cas);
$pgt_storage->write($pgt, $pgt_iou); $pgt_storage->write($pgt, $pgt_iou);
$this->render_nothing(); $this->render_nothing();
......
<?php <?php
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/** /**
* Stud.IP authentication against CAS Server * Stud.IP authentication against CAS Server
* *
...@@ -10,18 +7,15 @@ ...@@ -10,18 +7,15 @@
* @package * @package
*/ */
require_once 'composer/jasig/phpcas/CAS.php';
require_once 'lib/classes/cas/CAS_PGTStorage_Cache.php'; require_once 'lib/classes/cas/CAS_PGTStorage_Cache.php';
class StudipAuthCAS extends StudipAuthSSO class StudipAuthCAS extends StudipAuthSSO
{ {
public $host; public $host;
public $port; public $port;
public $uri; public $uri;
public $cacert; public $cacert;
public $cas;
public $userdata; public $userdata;
/** /**
...@@ -37,18 +31,19 @@ class StudipAuthCAS extends StudipAuthSSO ...@@ -37,18 +31,19 @@ class StudipAuthCAS extends StudipAuthSSO
$this->login_description = _('für Single Sign On mit CAS'); $this->login_description = _('für Single Sign On mit CAS');
} }
if (Request::get('sso') === $this->plugin_name) { if (Request::get('sso') === $this->plugin_name) {
$this->cas = new CAS_Client(CAS_VERSION_2_0, $this->proxy, $this->host, $this->port, $this->uri, false);
if ($this->proxy) { if ($this->proxy) {
URLHelper::setBaseUrl($GLOBALS['ABSOLUTE_URI_STUDIP']); URLHelper::setBaseUrl($GLOBALS['ABSOLUTE_URI_STUDIP']);
$this->cas->setPGTStorage(new CAS_PGTStorage_Cache($this->cas)); $cas = phpCAS::proxy(CAS_VERSION_2_0, $this->host, $this->port, $this->uri, false);
$this->cas->setCallbackURL(URLHelper::getURL('dispatch.php/cas/proxy')); phpCAS::setPGTStorage(new CAS_PGTStorage_Cache($cas));
phpCAS::setFixedCallbackURL(URLHelper::getURL('dispatch.php/cas/proxy'));
} else {
phpCAS::client(CAS_VERSION_2_0, $this->host, $this->port, $this->uri, false);
} }
if (isset($this->cacert)) { if (isset($this->cacert)) {
$this->cas->setCasServerCACert($this->cacert); phpCAS::setCasServerCACert($this->cacert);
} else { } else {
$this->cas->setNoCasServerValidation(); phpCAS::setNoCasServerValidation();
} }
} }
} }
...@@ -58,7 +53,7 @@ class StudipAuthCAS extends StudipAuthSSO ...@@ -58,7 +53,7 @@ class StudipAuthCAS extends StudipAuthSSO
*/ */
function getUser() function getUser()
{ {
return $this->cas->getUser(); return phpCAS::getUser();
} }
/** /**
...@@ -67,7 +62,7 @@ class StudipAuthCAS extends StudipAuthSSO ...@@ -67,7 +62,7 @@ class StudipAuthCAS extends StudipAuthSSO
*/ */
function verifyUsername($username) function verifyUsername($username)
{ {
$this->cas->forceAuthentication(); phpCAS::forceAuthentication();
return $this->getUser(); return $this->getUser();
} }
...@@ -82,13 +77,13 @@ class StudipAuthCAS extends StudipAuthSSO ...@@ -82,13 +77,13 @@ class StudipAuthCAS extends StudipAuthSSO
if (empty($this->userdata)) { if (empty($this->userdata)) {
$this->userdata = new $userdataclassname(); $this->userdata = new $userdataclassname();
} }
return $this->userdata->getUserData($key, $this->cas->getUser()); return $this->userdata->getUserData($key, phpCAS::getUser());
} }
function logout() function logout()
{ {
// do a global cas logout // do a global cas logout
$this->cas = new CAS_Client(CAS_VERSION_2_0, false, $this->host, $this->port, $this->uri, false); phpCAS::client(CAS_VERSION_2_0, $this->host, $this->port, $this->uri, false);
$this->cas->logout(); phpCAS::logout();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment