5 use \SimpleSAML_Auth_Source as Source;
6 use \SimpleSAML_Auth_State as State;
8 use \SimpleSAML_Error_AuthSource as AuthSourceError;
9 use \SimpleSAML\Module;
10 use \SimpleSAML_Session as
Session;
11 use \SimpleSAML\Utils\HTTP;
40 assert(
'is_string($authSource)');
43 $this->app_config = Configuration::getInstance()->getConfigItem(
'application', null);
56 $as = Source::getById($this->authSource);
58 throw new AuthSourceError($this->authSource,
'Unknown authentication source.');
74 $session = Session::getSessionFromRequest();
76 return $session->isValid($this->authSource);
96 $session = Session::getSessionFromRequest();
98 if (
$session->isValid($this->authSource)) {
124 if (array_key_exists(
'KeepPost',
$params)) {
125 $keepPost = (bool)
$params[
'KeepPost'];
130 if (array_key_exists(
'ReturnTo',
$params)) {
133 if (array_key_exists(
'ReturnCallback',
$params)) {
140 if (is_string(
$returnTo) && $keepPost &&
$_SERVER[
'REQUEST_METHOD'] ===
'POST') {
144 if (array_key_exists(
'ErrorURL',
$params)) {
157 $params[State::RESTART] = $restartURL;
183 assert(
'is_array($params) || is_string($params) || is_null($params)');
195 assert(
'is_array($params)');
196 assert(
'isset($params["ReturnTo"]) || isset($params["ReturnCallback"])');
198 if (isset(
$params[
'ReturnStateParam']) || isset(
$params[
'ReturnStateStage'])) {
199 assert(
'isset($params["ReturnStateParam"]) && isset($params["ReturnStateStage"])');
202 $session = Session::getSessionFromRequest();
203 if (
$session->isValid($this->authSource)) {
209 $session->doLogout($this->authSource);
211 $params[
'LogoutCompletedHandler'] =
array(get_class(),
'logoutCompleted');
213 $as = Source::getById($this->authSource);
219 self::logoutCompleted(
$params);
232 assert(
'is_array($state)');
233 assert(
'isset($state["ReturnTo"]) || isset($state["ReturnCallback"])');
235 if (isset(
$state[
'ReturnCallback'])) {
240 if (isset(
$state[
'ReturnStateParam']) || isset(
$state[
'ReturnStateStage'])) {
241 assert(
'isset($state["ReturnStateParam"]) && isset($state["ReturnStateStage"])');
242 $stateID = State::saveState(
$state,
$state[
'ReturnStateStage']);
267 $session = Session::getSessionFromRequest();
268 return $session->getAuthData($this->authSource,
'Attributes');
281 assert(
'is_string($name)');
287 $session = Session::getSessionFromRequest();
304 $session = Session::getSessionFromRequest();
305 return $session->getAuthState($this->authSource);
319 assert(
'is_null($returnTo) || is_string($returnTo)');
326 'AuthId' => $this->authSource,
344 assert(
'is_null($returnTo) || is_string($returnTo)');
351 'AuthId' => $this->authSource,
372 $url = HTTP::getSelfURL();
375 $scheme = parse_url(
$url, PHP_URL_SCHEME);
377 $port = parse_url(
$url, PHP_URL_PORT) ?: (
381 $path = parse_url(
$url, PHP_URL_PATH) ?:
'/';
382 $query = parse_url(
$url, PHP_URL_QUERY) ?:
'';
383 $fragment = parse_url(
$url, PHP_URL_FRAGMENT) ?:
'';
385 $port = !empty($port) ?
':'.$port :
'';
386 if (($scheme ===
'http' && $port ===
':80') || ($scheme ===
'https' && $port ===
':443')) {
390 if (is_null($this->app_config)) {
392 return $scheme.
'://'.$host.$port.$path.($query ?
'?'.$query :
'').($fragment ?
'#'.$fragment :
'');
395 $base = trim($this->app_config->getString(
397 $scheme.
'://'.$host.$port
399 return $base.$path.($query ?
'?'.$query :
'').($fragment ?
'#'.$fragment :
'');
if(!isset($_REQUEST['ReturnTo'])) $returnTo
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
getAuthDataArray()
Retrieve all authentication data.
static getServerHTTPS()
Retrieve HTTPS status from $_SERVER environment variables.
getLoginURL($returnTo=null)
Retrieve a URL that can be used to log the user in.
isAuthenticated()
Check if the user is authenticated.
getAuthData($name)
Retrieve authentication data.
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
login(array $params=array())
Start an authentication process.
logout($params=null)
Log the user out.
getAttributes()
Retrieve attributes of the current user.
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
__construct($authSource)
Create an instance with the specified authsource.
getAuthSource()
Retrieve the implementing authentication source.
getProcessedURL($url=null)
Process a URL and modify it according to the application/baseURL configuration option, if present.
static getSelfHost()
Retrieve our own host.
requireAuth(array $params=array())
Require the user to be authenticated.
Create styles array
The data for the language used.
"Manueller" Session-Fallback mit PHP4
static getServerPort()
Retrieve the port number from $_SERVER environment variables.
getLogoutURL($returnTo=null)
Retrieve a URL that can be used to log the user out.
static getPOSTRedirectURL($destination, $data)
Create a link which will POST data.
static logoutCompleted($state)
Called when logout operation completes.