当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleSAML_Session::getSessionFromRequest方法代码示例

本文整理汇总了PHP中SimpleSAML_Session::getSessionFromRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Session::getSessionFromRequest方法的具体用法?PHP SimpleSAML_Session::getSessionFromRequest怎么用?PHP SimpleSAML_Session::getSessionFromRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleSAML_Session的用法示例。


在下文中一共展示了SimpleSAML_Session::getSessionFromRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 public function process(&$state)
 {
     assert('is_array($state)');
     if (empty($state['Expire']) || empty($state['Authority'])) {
         return;
     }
     $now = time();
     $delta = $state['Expire'] - $now;
     $globalConfig = SimpleSAML_Configuration::getInstance();
     $sessionDuration = $globalConfig->getInteger('session.duration', 8 * 60 * 60);
     /* Extend only if half of session duration already passed */
     if ($delta >= $sessionDuration * 0.5) {
         return;
     }
     /* Update authority expire time */
     $session = SimpleSAML_Session::getSessionFromRequest();
     $session->setAuthorityExpire($state['Authority']);
     /* Update session cookies duration */
     /* If remember me is active */
     $rememberMeExpire = $session->getRememberMeExpire();
     if (!empty($state['RememberMe']) && $rememberMeExpire !== NULL && $globalConfig->getBoolean('session.rememberme.enable', FALSE)) {
         $session->setRememberMeExpire();
         return;
     }
     /* Or if session lifetime is more than zero */
     $sessionHandler = SimpleSAML_SessionHandler::getSessionHandler();
     $cookieParams = $sessionHandler->getCookieParams();
     if ($cookieParams['lifetime'] > 0) {
         $session->updateSessionCookies();
     }
 }
开发者ID:tractorcow,项目名称:simplesamlphp,代码行数:31,代码来源:ExtendIdPSession.php

示例2: checkLoggedAndSameAuth

 public static function checkLoggedAndSameAuth()
 {
     $session = SimpleSAML_Session::getSessionFromRequest();
     $uregconf = SimpleSAML_Configuration::getConfig('module_selfregister.php');
     $asId = $uregconf->getString('auth');
     $as = new SimpleSAML_Auth_Simple($asId);
     if ($as->isAuthenticated()) {
         return $as;
     }
     return false;
 }
开发者ID:GEANT,项目名称:simplesamlphp-module-selfregister,代码行数:11,代码来源:Util.php

示例3: initLogoutReturn

 /**
  * @deprecated This method will be removed in SSP 2.0.
  */
 public static function initLogoutReturn($returnURL, $authority)
 {
     assert('is_string($returnURL)');
     assert('is_string($authority)');
     $session = SimpleSAML_Session::getSessionFromRequest();
     $state = $session->getAuthData($authority, 'LogoutState');
     $session->doLogout($authority);
     $state['SimpleSAML_Auth_Default.ReturnURL'] = $returnURL;
     $state['LogoutCompletedHandler'] = array(get_class(), 'logoutCompleted');
     $as = SimpleSAML_Auth_Source::getById($authority);
     if ($as === NULL) {
         // The authority wasn't an authentication source...
         self::logoutCompleted($state);
     }
     $as->logout($state);
 }
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:19,代码来源:Default.php

示例4: __construct

 /**
  * Initializes this discovery service.
  *
  * The constructor does the parsing of the request. If this is an invalid request, it will
  * throw an exception.
  *
  * @param array $metadataSets  Array with metadata sets we find remote entities in.
  * @param string $instance  The name of this instance of the discovery service.
  */
 public function __construct(array $metadataSets, $instance)
 {
     assert('is_string($instance)');
     /* Initialize standard classes. */
     $this->config = SimpleSAML_Configuration::getInstance();
     $this->metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
     $this->session = SimpleSAML_Session::getSessionFromRequest();
     $this->instance = $instance;
     $this->metadataSets = $metadataSets;
     $this->log('Accessing discovery service.');
     /* Standard discovery service parameters. */
     if (!array_key_exists('entityID', $_GET)) {
         throw new Exception('Missing parameter: entityID');
     } else {
         $this->spEntityId = $_GET['entityID'];
     }
     if (!array_key_exists('returnIDParam', $_GET)) {
         $this->returnIdParam = 'entityID';
     } else {
         $this->returnIdParam = $_GET['returnIDParam'];
     }
     $this->log('returnIdParam initially set to [' . $this->returnIdParam . ']');
     if (!array_key_exists('return', $_GET)) {
         throw new Exception('Missing parameter: return');
     } else {
         $this->returnURL = SimpleSAML_Utilities::checkURLAllowed($_GET['return']);
     }
     $this->isPassive = FALSE;
     if (array_key_exists('isPassive', $_GET)) {
         if ($_GET['isPassive'] === 'true') {
             $this->isPassive = TRUE;
         }
     }
     $this->log('isPassive initially set to [' . ($this->isPassive ? 'TRUE' : 'FALSE') . ']');
     if (array_key_exists('IdPentityID', $_GET)) {
         $this->setIdPentityID = $_GET['IdPentityID'];
     } else {
         $this->setIdPentityID = NULL;
     }
     if (array_key_exists('IDPList', $_REQUEST)) {
         $this->scopedIDPList = $_REQUEST['IDPList'];
     }
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:52,代码来源:IdPDisco.php

示例5: handleLogoutResponse

 /**
  * Process a logout response.
  *
  * This function will never return.
  *
  * @param string                          $assocId The association that is terminated.
  * @param string|null                     $relayState The RelayState from the start of the logout.
  * @param SimpleSAML_Error_Exception|null $error The error that occurred during session termination (if any).
  */
 public function handleLogoutResponse($assocId, $relayState, SimpleSAML_Error_Exception $error = null)
 {
     assert('is_string($assocId)');
     assert('is_string($relayState) || is_null($relayState)');
     $session = SimpleSAML_Session::getSessionFromRequest();
     $session->deleteData('core:idp-ssotime', $this->id . ';' . substr($assocId, strpos($assocId, ':') + 1));
     $handler = $this->getLogoutHandler();
     $handler->onResponse($assocId, $relayState, $error);
     assert('false');
 }
开发者ID:SysBind,项目名称:simplesamlphp,代码行数:19,代码来源:IdP.php

示例6: isAdmin

 /**
  * Check whether the current user is admin.
  *
  * @return boolean True if the current user is an admin user, false otherwise.
  *
  * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
  */
 public static function isAdmin()
 {
     $session = \SimpleSAML_Session::getSessionFromRequest();
     return $session->isValid('admin') || $session->isValid('login-admin');
 }
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:12,代码来源:Auth.php

示例7: handleUnsolicitedAuth

 /**
  * Handle a unsolicited login operations.
  *
  * This function creates a session from the received information. It
  * will then redirect to the given URL.
  *
  * This is used to handle IdP initiated SSO.
  *
  * @param string $authId The id of the authentication source that received
  * the request.
  * @param array $state A state array.
  * @param string $redirectTo The URL we should redirect the user to after
  * updating the session. The function will check if the URL is allowed, so
  * there is no need to manually check the URL on beforehand. Please refer
  * to the 'trusted.url.domains' configuration directive for more
  * information about allowing (or disallowing) URLs.
  */
 public static function handleUnsolicitedAuth($authId, array $state, $redirectTo)
 {
     assert('is_string($authId)');
     assert('is_string($redirectTo)');
     $session = SimpleSAML_Session::getSessionFromRequest();
     $session->doLogin($authId, self::extractPersistentAuthState($state));
     SimpleSAML_Utilities::redirectUntrustedURL($redirectTo);
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:25,代码来源:Default.php

示例8: logout

 /**
  * Log out from this authentication source.
  *
  * This method retrieves the authentication source used for this
  * session and then call the logout method on it.
  *
  * @param array &$state	 Information about the current logout operation.
  */
 public function logout(&$state)
 {
     assert('is_array($state)');
     /* Get the source that was used to authenticate */
     $session = SimpleSAML_Session::getSessionFromRequest();
     $authId = $session->getData(self::SESSION_SOURCE, $this->authId);
     $source = SimpleSAML_Auth_Source::getById($authId);
     if ($source === NULL) {
         throw new Exception('Invalid authentication source during logout: ' . $source);
     }
     /* Then, do the logout on it */
     $source->logout($state);
 }
开发者ID:simplesamlphp,项目名称:simplesamlphp,代码行数:21,代码来源:MultiAuth.php

示例9: logout

 /**
  * Logout. 
  * 
  * @see SimpleSAML_Auth_Source::logout()
  */
 public function logout(&$state)
 {
     parent::logout($state);
     $server = sspmod_authTiqr_Auth_Tiqr::getServer(false);
     $session = SimpleSAML_Session::getSessionFromRequest();
     $sessionId = $session->getSessionId();
     $server->logout($sessionId);
 }
开发者ID:RKathees,项目名称:is-connectors,代码行数:13,代码来源:TiqrUserPass.php

示例10: deleteState

 /**
  * Delete state.
  *
  * This function deletes the given state to prevent the user from reusing it later.
  *
  * @param array &$state  The state which should be deleted.
  */
 public static function deleteState(&$state)
 {
     assert('is_array($state)');
     if (!array_key_exists(self::ID, $state)) {
         /* This state hasn't been saved. */
         return;
     }
     SimpleSAML_Logger::debug('Deleting state: ' . var_export($state[self::ID], TRUE));
     $session = SimpleSAML_Session::getSessionFromRequest();
     $session->deleteData('SimpleSAML_Auth_State', $state[self::ID]);
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:18,代码来源:State.php

示例11: getPOSTRedirectURL

 /**
  * Create a link which will POST data.
  *
  * @param string $destination The destination URL.
  * @param array  $data The name-value pairs which will be posted to the destination.
  *
  * @return string  A URL which can be accessed to post the data.
  * @throws \InvalidArgumentException If $destination is not a string or $data is not an array.
  *
  * @author Andjelko Horvat
  * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
  */
 public static function getPOSTRedirectURL($destination, $data)
 {
     if (!is_string($destination) || !is_array($data)) {
         throw new \InvalidArgumentException('Invalid input parameters.');
     }
     $config = \SimpleSAML_Configuration::getInstance();
     $allowed = $config->getBoolean('enable.http_post', false);
     if ($allowed && preg_match("#^http:#", $destination) && self::isHTTPS()) {
         // we need to post the data to HTTP
         $url = self::getSecurePOSTRedirectURL($destination, $data);
     } else {
         // post the data directly
         $session = \SimpleSAML_Session::getSessionFromRequest();
         $id = self::savePOSTData($session, $destination, $data);
         $url = \SimpleSAML_Module::getModuleURL('core/postredirect.php', array('RedirId' => $id));
     }
     return $url;
 }
开发者ID:mrvanes,项目名称:simplesamlphp,代码行数:30,代码来源:HTTP.php

示例12: logout

 /**
  * Log out from this authentication source.
  *
  * This method either logs the user out from Negotiate or passes the
  * logout call to the fallback module.
  *
  * @param array &$state Information about the current logout operation.
  */
 public function logout(&$state)
 {
     assert('is_array($state)');
     // get the source that was used to authenticate
     $authId = $state['negotiate:backend'];
     SimpleSAML_Logger::debug('Negotiate - logout has the following authId: "' . $authId . '"');
     if ($authId === null) {
         $session = SimpleSAML_Session::getSessionFromRequest();
         $session->setData('negotiate:disable', 'session', true, 24 * 60 * 60);
         parent::logout($state);
     } else {
         $source = SimpleSAML_Auth_Source::getById($authId);
         $source->logout($state);
     }
 }
开发者ID:Chialab,项目名称:simplesamlphp,代码行数:23,代码来源:Negotiate.php

示例13: addSession

 /**
  * Register a new session in the datastore.
  *
  * @param string $authId  The authsource ID.
  * @param array $nameId  The NameID of the user.
  * @param string|NULL $sessionIndex  The SessionIndex of the user.
  */
 public static function addSession($authId, array $nameId, $sessionIndex, $expire)
 {
     assert('is_string($authId)');
     assert('is_string($sessionIndex) || is_null($sessionIndex)');
     assert('is_int($expire)');
     if ($sessionIndex === NULL) {
         /* This IdP apparently did not include a SessionIndex, and thus probably does not
          * support SLO. We still want to add the session to the data store just in case
          * it supports SLO, but we don't want an LogoutRequest with a specific
          * SessionIndex to match this session. We therefore generate our own session index.
          */
         $sessionIndex = SimpleSAML\Utils\Random::generateID();
     }
     $store = SimpleSAML_Store::getInstance();
     if ($store === FALSE) {
         // We don't have a datastore.
         return;
     }
     /* Normalize NameID. */
     ksort($nameId);
     $strNameId = serialize($nameId);
     $strNameId = sha1($strNameId);
     /* Normalize SessionIndex. */
     if (strlen($sessionIndex) > 50) {
         $sessionIndex = sha1($sessionIndex);
     }
     $session = SimpleSAML_Session::getSessionFromRequest();
     $sessionId = $session->getSessionId();
     if ($store instanceof SimpleSAML_Store_SQL) {
         self::addSessionSQL($store, $authId, $strNameId, $sessionIndex, $expire, $sessionId);
     } else {
         $store->set('saml.LogoutStore', $strNameId . ':' . $sessionIndex, $sessionId, $expire);
     }
 }
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:41,代码来源:LogoutStore.php

示例14: logout

 /**
  * Start a logout operation.
  *
  * @param string|NULL $url  The URL the user should be redirected to after logging out.
  *                          Defaults to the current page.
  * @deprecated
  */
 public function logout($url = NULL)
 {
     if ($url === NULL) {
         $url = SimpleSAML_Utilities::selfURL();
     }
     $session = SimpleSAML_Session::getSessionFromRequest();
     if (!$session->isValid($this->authority)) {
         /* Not authenticated to this authentication source. */
         SimpleSAML_Utilities::redirectTrustedURL($url);
         assert('FALSE');
     }
     if ($this->authority === 'saml2') {
         $config = SimpleSAML_Configuration::getInstance();
         SimpleSAML_Utilities::redirectTrustedURL('/' . $config->getBaseURL() . 'saml2/sp/initSLO.php', array('RelayState' => $url));
     }
     $session->doLogout($this->authority);
     SimpleSAML_Utilities::redirectTrustedURL($url);
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:25,代码来源:BWC.php

示例15: show

 /**
  * Display this error.
  *
  * This method displays a standard simpleSAMLphp error page and exits.
  */
 public function show()
 {
     $this->setHTTPCode();
     /* Log the error message. */
     $this->logError();
     $errorData = $this->saveError();
     $config = SimpleSAML_Configuration::getInstance();
     $data['showerrors'] = $config->getBoolean('showerrors', true);
     $data['error'] = $errorData;
     $data['errorCode'] = $this->errorCode;
     $data['parameters'] = $this->parameters;
     $data['module'] = $this->module;
     $data['dictTitle'] = $this->dictTitle;
     $data['dictDescr'] = $this->dictDescr;
     $data['includeTemplate'] = $this->includeTemplate;
     /* Check if there is a valid technical contact email address. */
     if ($config->getBoolean('errorreporting', TRUE) && $config->getString('technicalcontact_email', 'na@example.org') !== 'na@example.org') {
         /* Enable error reporting. */
         $baseurl = SimpleSAML_Utilities::getBaseURL();
         $data['errorReportAddress'] = $baseurl . 'errorreport.php';
     }
     $session = SimpleSAML_Session::getSessionFromRequest();
     $attributes = $session->getAttributes();
     if (is_array($attributes) && array_key_exists('mail', $attributes) && count($attributes['mail']) > 0) {
         $data['email'] = $attributes['mail'][0];
     } else {
         $data['email'] = '';
     }
     $show_function = $config->getArray('errors.show_function', NULL);
     if (isset($show_function)) {
         assert('is_callable($show_function)');
         call_user_func($show_function, $config, $data);
         assert('FALSE');
     } else {
         $t = new SimpleSAML_XHTML_Template($config, 'error.php', 'errors');
         $t->data = array_merge($t->data, $data);
         $t->show();
     }
     exit;
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:45,代码来源:Error.php


注:本文中的SimpleSAML_Session::getSessionFromRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。