本文整理汇总了PHP中SimpleSAML_Session类的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Session类的具体用法?PHP SimpleSAML_Session怎么用?PHP SimpleSAML_Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleSAML_Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: saveSession
/**
* Save a session to the data store.
*
* @param SimpleSAML_Session $session The session object we should save.
*/
public function saveSession(SimpleSAML_Session $session)
{
$sessionId = $session->getSessionId();
$config = SimpleSAML_Configuration::getInstance();
$sessionDuration = $config->getInteger('session.duration', 8 * 60 * 60);
$expire = time() + $sessionDuration;
$this->store->set('session', $sessionId, $session, $expire);
}
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:13,代码来源:SessionHandlerStore.php
示例2: newSessionId
/**
* Create and set new session id.
*
* @return string The new session id.
*/
public function newSessionId()
{
$this->session_id = self::createSessionID();
SimpleSAML_Session::createSession($this->session_id);
$this->setCookie($this->cookie_name, $this->session_id);
return $this->session_id;
}
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:12,代码来源:SessionHandlerCookie.php
示例3: 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
示例4: loginComplete
/**
* When login is complete, save the SSPAuthentication object to the session
*/
public final function loginComplete()
{
//Use the same session as SimpleSAMLphp to avoid session state loss
Session::start(SimpleSAML_Session::getInstance()->getSessionId());
Session::set('ssp_current_auth_source', $this->getAuthSource()->getAuthId());
Session::set('ssp_current_auth_class', get_class($this));
Session::save();
}
开发者ID:helpfulrobot,项目名称:antons-silverstripe-ssp,代码行数:11,代码来源:SSPAuthenticator.php
示例5: getUser
function getUser(SimpleSAML_Session $session, ConfigProxy $janus_config)
{
// Get data from config
/** @var string $useridattr */
$useridattr = $janus_config->getValue('useridattr', 'eduPersonPrincipalName');
// Validate user
$attributes = $session->getAttributes();
// Check if userid exists
if (!isset($attributes[$useridattr])) {
echo json_encode(array('status' => 'user_id_is_missing'));
exit;
}
$userid = $attributes[$useridattr][0];
$user = new sspmod_janus_User();
$user->setUserid($userid);
$user->load(sspmod_janus_User::USERID_LOAD);
return $user;
}
开发者ID:baszoetekouw,项目名称:janus,代码行数:18,代码来源:AJAXRequestHandler.php
示例6: 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
示例7: show
/**
* Display this error.
*
* This method displays a standard simpleSAMLphp error page and exits.
*/
public function show()
{
$this->setHTTPCode();
$session = SimpleSAML_Session::getInstance();
if ($this->cause !== NULL) {
$e = $this->cause;
} else {
$e = $this;
}
SimpleSAML_Utilities::fatalError($session->getTrackID(), $this->errorCode, $e);
}
开发者ID:hukumonline,项目名称:yii,代码行数:16,代码来源:Error.php
示例8: checkLoggedAndSameAuth
public static function checkLoggedAndSameAuth()
{
$session = SimpleSAML_Session::getInstance();
if ($session->isAuthenticated()) {
$uregconf = SimpleSAML_Configuration::getConfig('module_selfregister.php');
/* Get a reference to our authentication source. */
$asId = $uregconf->getString('auth');
if ($session->getAuthority() == $asId) {
return new SimpleSAML_Auth_Simple($asId);
}
}
return false;
}
开发者ID:googlecode-mirror,项目名称:simplesamlphp-labs,代码行数:13,代码来源:Util.php
示例9: process
/**
* Apply filter to add the UID attribute.
*
* @param array &$request The current request
*/
public function process(&$request)
{
assert('is_array($request)');
assert('array_key_exists("Attributes", $request)');
$authModule = NULL;
// Fetch Auth module
if (array_key_exists("SimpleSAML_Auth_State.stage", $request)) {
$authStage = implode(":", array_slice(explode(':', $request["SimpleSAML_Auth_State.stage"]), 0, -1));
$authId = $authStage . ':AuthId';
$authModule = $request[$authId];
} else {
if (isset($request['AuthnInstant']) && isset($request['Expire'])) {
// Probably dealing with a cached response
$cachedAuthModule = SimpleSAML_Session::getInstance()->getData(sspmod_multiauth_Auth_Source_MultiAuth::SESSION_SOURCE, 'multi');
if ($cachedAuthModule) {
$authModule = $cachedAuthModule;
}
}
}
if (!isset($authModule)) {
throw new Exception("Auth module not found?!?!");
}
$attributes =& $request['Attributes'];
$filter = null;
// Set or replace the filter attribute
if (array_key_exists($authModule, $this->map)) {
$filter = $this->map[$authModule];
}
switch ($filter) {
case 'GOOGLE':
$attributes['uid'] = $this->_useEmailAsUid($attributes);
break;
case 'YAHOO':
$attributes['uid'] = $this->_useEmailAsUid($attributes);
break;
case 'HYVES':
if (!array_key_exists('openid.local_id', $attributes)) {
throw new Exception('No local id attribute provided! Cannot use it as UID');
}
$attributes['uid'] = str_replace('.hyves.nl/', '', str_replace('http://', '', $attributes['openid.local_id']));
break;
default:
if (!array_key_exists('uid', $attributes)) {
throw new Exception('No UID set?!?!');
}
break;
}
}
开发者ID:WebSpider,项目名称:OpenConext-guestidp,代码行数:53,代码来源:SetUid.php
示例10: 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
示例11: getCookieSessionId
/**
* Retrieve the session id of saved in the session cookie.
*
* @return string The session id saved in the cookie.
*/
public function getCookieSessionId()
{
if ($this->session_id === NULL) {
if (self::hasSessionCookie()) {
/* Attempt to retrieve the session id from the cookie. */
$this->session_id = $_COOKIE[$this->cookie_name];
}
/* Check if we have a valid session id. */
if (!self::isValidSessionID($this->session_id)) {
/* We don't have a valid session. Create a new session id. */
$this->session_id = self::createSessionID();
SimpleSAML_Session::createSession($this->session_id);
$this->setCookie($this->cookie_name, $this->session_id);
}
}
return $this->session_id;
}
开发者ID:rchavik,项目名称:simplesamlphp,代码行数:22,代码来源:SessionHandlerCookie.php
示例12: __construct
/**
* Constructor
*
* Note that the person is tied to a session and a simplesaml configuration
* here
*/
function __construct($person = NULL)
{
parent::__construct($person);
/* Find the path to simpelsamlphp and run the autoloader */
try {
$sspdir = Config::get_config('simplesaml_path');
} catch (KeyNotFoundException $knfe) {
echo "Cannot find path to simplesaml. This install is not valid. Aborting.<br />\n";
Logger::logEvent(LOG_ALERT, "Confusa_Auth_IdP", "__construct()", "Trying to instantiate SimpleSAMLphp without a configured path.");
exit(0);
}
require_once $sspdir . '/lib/_autoload.php';
SimpleSAML_Configuration::setConfigDir($sspdir . '/config');
/* start a session needed for the IdP-based AuthN approach */
$this->as = new SimpleSAML_Auth_Simple('default-sp');
$this->session = SimpleSAML_Session::getInstance();
}
开发者ID:henrikau,项目名称:confusa,代码行数:23,代码来源:Confusa_Auth_IdP.php
示例13: authenticate
/**
* Log-in using Facebook platform
*
* @param array &$state Information about the current authentication.
*/
public function authenticate(&$state)
{
assert('is_array($state)');
/* We are going to need the authId in order to retrieve this authentication source later. */
$state[self::AUTHID] = $this->authId;
$stateID = SimpleSAML_Auth_State::saveState($state, self::STAGE_INIT);
// SimpleSAML_Logger::debug('facebook auth state id = ' . $stateID);
$consumer = new sspmod_oauth_Consumer($this->key, $this->secret);
// Get the request token
$requestToken = $consumer->getRequestToken('http://twitter.com/oauth/request_token');
SimpleSAML_Logger::debug("Got a request token from the OAuth service provider [" . $requestToken->key . "] with the secret [" . $requestToken->secret . "]");
$oauthState = array('requestToken' => serialize($requestToken), 'stateid' => $stateID);
$session = SimpleSAML_Session::getInstance();
$session->setData('oauth', 'oauth', $oauthState);
// Authorize the request token
$consumer->getAuthorizeRequest('http://twitter.com/oauth/authenticate', $requestToken);
}
开发者ID:filonuse,项目名称:fedlab,代码行数:22,代码来源:Twitter.php
示例14: __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
示例15: newSessionId
/**
* Create and set new session id.
*
* @return string The new session id.
*/
public function newSessionId()
{
$session_cookie_params = session_get_cookie_params();
if ($session_cookie_params['secure'] && !SimpleSAML_Utilities::isHTTPS()) {
throw new SimpleSAML_Error_Exception('Session start with secure cookie not allowed on http.');
}
if (headers_sent()) {
throw new SimpleSAML_Error_Exception('Cannot create new session - headers already sent.');
}
/* Generate new (secure) session id. */
$sessionId = SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(16));
SimpleSAML_Session::createSession($sessionId);
if (session_id() !== '') {
/* Session already started, close it. */
session_write_close();
}
session_id($sessionId);
session_start();
return session_id();
}
开发者ID:williamamed,项目名称:Raptor2,代码行数:25,代码来源:SessionHandlerPHP.php
示例16: authenticate
public function authenticate(TokenInterface $token)
{
/** @var string $authenticationType */
$authenticationType = $this->config->getValue('auth', 'login-admin');
if (php_sapi_name() === 'cli') {
return $this->getTokenForUsername($authenticationType);
}
$session = \SimpleSAML_Session::getInstance();
if (!$session->isValid($authenticationType)) {
throw new AuthenticationException("Authsource '{$authenticationType}' is invalid");
}
/** @var string $userIdAttributeName */
$userIdAttributeName = $this->config->getValue('useridattr', 'eduPersonPrincipalName');
// Check if userid exists
$attributes = $session->getAttributes();
if (!isset($attributes[$userIdAttributeName])) {
throw new AuthenticationException("Attribute '{$userIdAttributeName}' with User ID is missing.");
}
return $this->getTokenForUsername($attributes[$userIdAttributeName][0]);
}
开发者ID:baszoetekouw,项目名称:janus,代码行数:20,代码来源:SspProvider.php
示例17: newSessionId
/**
* Create and set new session id.
*
* @return string The new session id.
*
* @throws SimpleSAML_Error_Exception If the cookie is marked as secure but we are not using HTTPS, or the headers
* were already sent and therefore we cannot set the cookie.
*/
public function newSessionId()
{
$session_cookie_params = session_get_cookie_params();
if ($session_cookie_params['secure'] && !\SimpleSAML\Utils\HTTP::isHTTPS()) {
throw new SimpleSAML_Error_Exception('Session start with secure cookie not allowed on http.');
}
if (headers_sent()) {
throw new SimpleSAML_Error_Exception('Cannot create new session - headers already sent.');
}
// generate new (secure) session id
$sessionId = bin2hex(openssl_random_pseudo_bytes(16));
SimpleSAML_Session::createSession($sessionId);
if (session_id() !== '') {
// session already started, close it
session_write_close();
}
session_id($sessionId);
session_start();
return session_id();
}
开发者ID:tractorcow,项目名称:simplesamlphp,代码行数:28,代码来源:SessionHandlerPHP.php
示例18: getCookieSessionId
/**
* Retrieve the session id of saved in the session cookie.
*
* @return string The session id saved in the cookie.
*/
public function getCookieSessionId()
{
if (session_id() === '') {
$session_cookie_params = session_get_cookie_params();
if ($session_cookie_params['secure'] && !SimpleSAML_Utilities::isHTTPS()) {
throw new SimpleSAML_Error_Exception('Session start with secure cookie not allowed on http.');
}
if (!self::hasSessionCookie()) {
if (headers_sent()) {
throw new SimpleSAML_Error_Exception('Cannot create new session - headers already sent.');
}
/* Session cookie unset - session id not set. Generate new (secure) session id. */
$sessionId = SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(16));
SimpleSAML_Session::createSession($sessionId);
session_id($sessionId);
}
session_start();
}
return session_id();
}
开发者ID:rchavik,项目名称:simplesamlphp,代码行数:25,代码来源:SessionHandlerPHP.php
示例19: show
/**
* Show the error to the user.
*
* This function does not return.
*/
public function show()
{
header('HTTP/1.0 500 Internal Server Error');
$errorData = $this->saveError();
$session = SimpleSAML_Session::getInstance();
$attributes = $session->getAttributes();
if (isset($attributes['mail'][0])) {
$email = $attributes['mail'][0];
} else {
$email = '';
}
$globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'core:no_state.tpl.php');
/* Enable error reporting if we have a valid technical contact email. */
if ($globalConfig->getString('technicalcontact_email', '[email protected]') !== '[email protected]') {
/* Enable error reporting. */
$baseurl = SimpleSAML_Utilities::getBaseURL();
$t->data['errorReportAddress'] = $baseurl . 'errorreport.php';
$t->data['reportId'] = $errorData['reportId'];
$t->data['email'] = $email;
}
$t->show();
exit;
}
开发者ID:filonuse,项目名称:fedlab,代码行数:29,代码来源:NoState.php
示例20: process
/**
* Apply filter to add the SchacHomeOrganization attribute.
*
* @param array &$request The current request
*/
public function process(&$request)
{
assert('is_array($request)');
assert('array_key_exists("Attributes", $request)');
$authModule = NULL;
// Fetch Auth module
if (array_key_exists("SimpleSAML_Auth_State.stage", $request)) {
$authStage = implode(":", array_slice(explode(':', $request["SimpleSAML_Auth_State.stage"]), 0, -1));
$authId = $authStage . ':AuthId';
$authModule = $request[$authId];
} else {
if (isset($request['AuthnInstant']) && isset($request['Expire'])) {
// Probably dealing with a cached response
$cachedAuthModule = SimpleSAML_Session::getInstance()->getData(sspmod_multiauth_Auth_Source_MultiAuth::SESSION_SOURCE, 'multi');
if ($cachedAuthModule) {
$authModule = $cachedAuthModule;
}
}
}
if (!isset($authModule)) {
throw new Exception("Auth module not found?!?!");
}
$attributes =& $request['Attributes'];
// Set or replace the schacHomeOrganization attribute
if (array_key_exists($authModule, $this->map)) {
$schacHomeOrganization = $this->map[$authModule];
if (isset($schacHomeOrganization)) {
$attributes["schacHomeOrganization"] = $schacHomeOrganization;
return;
}
}
if (array_key_exists(DEFAULT_SCHACHOMEORG, $this->map)) {
throw new Exception("No default schacHomeOrganization?!?");
}
$attributes["schacHomeOrganization"] = $this->map[DEFAULT_SCHACHOMEORG];
}
开发者ID:WebSpider,项目名称:OpenConext-guestidp,代码行数:41,代码来源:SchacHomeOrganization.php
注:本文中的SimpleSAML_Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论