public function postAuthorize() { $user = Shibboleth::user(); $userId = $user->eduPersonPrincipalName; $owner = Owner::find($userId); if (!$owner) { $owner = new Owner(); $owner->id = $userId; } $owner->data = json_encode($user); $owner->save(); $params = Session::get('authorize-params'); $params['user_id'] = $user->eduPersonPrincipalName; if (Input::get('approve') !== null) { $code = AuthorizationServer::newAuthorizeRequest('user', $params['user_id'], $params); Session::forget('authorize-params'); return Redirect::to(AuthorizationServer::makeRedirectWithCode($code, $params)); } if (Input::get('deny') !== null) { Session::forget('authorize-params'); $url = AuthorizationServer::makeRedirectWithError($params); return new \Illuminate\Http\RedirectResponse((string) $url, 302, array()); } }
static function test_new_no_affiliation_default() { self::init(); self::helper()->setup_new_no_affiliation(); $shib_user = Shibboleth::store()->get_user(); self::assert($config = Shibboleth::config()->default_status == Shibboleth::STUDENT_STATUS); self::assert(!User::store()->shibboleth_id_exists($shib_user->unique_id)); self::assert($shib_user->affiliation == ''); Shibboleth::save($shib_user); $user = User::store()->get_by_shibboleth_id($shib_user->unique_id); self::assert($user->email == $shib_user->email); self::assert($user->firstname == 'John'); self::assert($user->lastname == $shib_user->lastname); self::assert($user->persistent_id == $shib_user->persistent_id); self::assert($user->status == Shibboleth::STUDENT_STATUS); self::assert(!empty($user->password)); self::assert(!empty($user->username)); }
/** * Returns the shibboleth value stored in $_SERVER if it exists or $default if it is not the case. * * @param string $name the generic name. I.e. one of the class const. * @param string $default default value if it is not provided by Shibboleth * @return string */ public function get($name = '', $default = '') { $config = (array) Shibboleth::config(); if ($name) { $name = str_replace('get_', '', $name); $shib_name = isset($config[$name]) ? $config[$name] : ''; if ($shib_name) { $result = isset($_SERVER[$shib_name]) ? $_SERVER[$shib_name] : $default; $result = explode(';', $result); if (empty($result)) { $result = $default; } else { if (count($result) == 1) { $result = reset($result); } else { $result = $result; } } return $result; } } $result = array(); foreach ($config as $key => $val) { $f = array($this, "get_{$key}"); if (is_callable($f)) { $result[$key] = call_user_func($f); } } return $result; }
<?php namespace Shibboleth; /** * @license see /license.txt * @author Laurent Opprecht <*****@*****.**>, Nicolas Rod for the University of Geneva */ include_once dirname(__FILE__) . '/../init.php'; if (!ShibbolethTest::is_enabled()) { echo 'This is not a test server'; die; } Shibboleth::session()->logout(); ShibbolethTest::helper()->setup_new_student_no_email(); require_once dirname(__FILE__) . '/../login.php';
<?php namespace Shibboleth; /** * Example of a config.php file. Not used. Configuration must appear in * config.php. * * By default set up the aai configuration. * * @license see /license.txt * @author Laurent Opprecht <*****@*****.**>, Nicolas Rod for the University of Geneva */ require_once dirname(__FILE__) . '/config/aai.class.php'; Shibboleth::set_config(aai::config());
<?php namespace Shibboleth; /** * Scaffold script. Generates the required database models for the Shibboleth * plugin. * * Will only run when the server is a test server. * * @license see /license.txt * @author Laurent Opprecht <*****@*****.**>, Nicolas Rod for the University of Geneva */ $dir = dirname(__FILE__); include_once $dir . '/../init.php'; include_once $dir . '/../app/lib/scaffolder/scaffolder.class.php'; if (!ShibbolethTest::is_enabled()) { echo 'This is not a test server'; die; } if (!Shibboleth::session()->is_logged_in()) { echo 'Not authorized'; die; } $name = 'user'; $result = Scaffolder::instance()->scaffold($name); file_put_contents("{$dir}/output/{$name}.class.php", $result); header('content-type: text/plain'); echo $result;