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


PHP SimpleSAML_Auth_Simple::isAuthenticated方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     //	Obligatoire
     parent::__construct();
     $this->data = array();
     // System FED Oxylane
     if (FEDACTIVE) {
         require __DIR__ . '/../simplesaml/lib/_autoload.php';
         $as = new SimpleSAML_Auth_Simple('Oxylane-sp');
         $isAuth = $as->isAuthenticated();
         if (!$isAuth) {
             $as->requireAuth();
         } else {
             $attributes = $as->getAttributes();
             $this->data['fed']['0'] = $attributes['uid'][0];
             //identifiant
             $this->data['fed']['1'] = $attributes['cn'][0];
             //nom de la personne
             $this->data['fed']['2'] = $attributes['mail'][0];
             //mail de la personne
         }
     } else {
         $this->data['fed']['0'] = "ID";
         $this->data['fed']['1'] = "NOM";
         $this->data['fed']['2'] = "MAIL";
     }
     // END FED
     //	Chargement des ressources pour tout le contrôleur
     $this->load->database();
     $this->load->helper('form');
     $this->load->helper('titreUrl');
     $this->load->helper('convertlien');
     $this->load->library('form_validation');
     $this->load->model('pages_model', 'pm');
     $this->load->model('plannings_model', 'plm');
     $this->load->model('types_model', 'tm');
     $this->load->model('chaines_model', 'cm');
     $this->load->model('groupes_model', 'gm');
     $this->load->model('bandeau_model', 'bm');
     if (FEDLOG) {
         $this->load->model('logs_model', 'lm');
     }
     // Récupération de toute les chaines
     $this->data['chaines'] = $this->cm->getAll();
     $this->data['superadmin'] = true;
     //	Cette méthode permet de changer les délimiteurs par défaut des messages d'erreur (<p></p>).
     $this->form_validation->set_error_delimiters('<p class="alert alert-error fade in"><a class="close" data-dismiss="alert" href="#">&times;</a>', '</p>');
 }
开发者ID:keyanmca,项目名称:webtv,代码行数:48,代码来源:admin.php

示例2: executeSignin

 public function executeSignin($request)
 {
     $user = $this->getUser();
     if ($user->isAuthenticated()) {
         return $this->redirect('@homepage');
     }
     // Create SimpleSAML module
     $simpleSAMLAuth = new SimpleSAML_Auth_Simple('default-sp');
     // If the user is authenticated from the IdP
     if ($simpleSAMLAuth->isAuthenticated()) {
         $attributes = $simpleSAMLAuth->getAttributes();
         // save the referer
         $user_referer = $user->getReferer($request->getReferer());
         // Try to find the user with his uid
         $query = Doctrine_Core::getTable('sfGuardUser')->createQuery('u')->where('u.username = ?', $attributes['eduPersonPrincipalName'][0]);
         // If the sGuardUser already exists in the database, it's OK
         if ($query->count() >= 1) {
             $guard_user = $query->fetchOne();
             $guard_user->setEmailAddress($attributes['mail'][0]);
             $guard_user->setLastName($attributes['cn'][0]);
             $guard_user->save();
         } else {
             // the user doesn't exist, we create a new one with random password
             $guard_user = new sfGuardUser();
             $guard_user->setUsername($attributes['eduPersonPrincipalName'][0]);
             $guard_user->setPassword(md5(microtime() . $attributes['eduPersonPrincipalName'][0] . mt_rand()));
             $guard_user->setEmailAddress($attributes['mail'][0]);
             $guard_user->setLastName($attributes['cn'][0]);
             $guard_user->setIsActive(true);
             $guard_user->save();
         }
         // Let the User signin
         // The auth is not rembered : the IdP can decide that
         $this->getUser()->signin($guard_user, $remember = false);
         // always redirect to a URL set in app.yml
         // or to the referer
         // or to the homepage
         $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user_referer);
         return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage');
     } else {
         if ($request->isXmlHttpRequest()) {
             $this->getResponse()->setHeaderOnly(true);
             $this->getResponse()->setStatusCode(401);
             return sfView::NONE;
         }
         // if we have been forwarded, then the referer is the current URL
         // if not, this is the referer of the current request
         $user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer());
         /* gyufi $this->url_idp = $simpleSAMLAuth->login(array(
              //'saml:idp' => 'https://openidp.feide.no',
              'saml:idp' => 'https://aai.sztaki.hu/idp-partners',
              'saml:idp' => 'https://aai.sztaki.hu/idp',
            ));
            */
         $this->url_idp = $simpleSAMLAuth->login();
         // Nothing happened after there, $simpleSAMLAuth->login() calls exit()
         /*
               $module = sfConfig::get('sf_login_module');
               if ($this->getModuleName() != $module)
               {
                 return $this->redirect($module.'/'.sfConfig::get('sf_login_action'));
               }
         
               $this->getResponse()->setStatusCode(401);
         */
     }
 }
开发者ID:br00k,项目名称:yavom,代码行数:67,代码来源:BasesfSAMLAuthActions.class.php

示例3: get_attributes

function get_attributes()
{
    // Only run in step 5 or later ! So change when steps array is changed!
    if (isset($_REQUEST['s'])) {
        if ($_REQUEST['s'] >= 4) {
            if ($ssp_location = issetweb('ssp_location')) {
                $ssp_autoloader = $ssp_location . '/lib/_autoload.php';
                if (is_readable($ssp_autoloader)) {
                    //echo "<pre>sesion:"; var_dump($_SESSION); echo "rquest"; var_dump($_REQUEST);
                    include_once $ssp_autoloader;
                    if ($ssp_authsource = issetweb('ssp_authsource')) {
                        $as = new SimpleSAML_Auth_Simple($ssp_authsource);
                        if (!$as->isAuthenticated()) {
                            $as->requireAuth();
                        }
                        $attributes = $as->getAttributes();
                        foreach (array_keys($attributes) as $at) {
                            // These are key|value pairs to populate the SELECT boxes
                            $simpleattrs[$at] = $at . " (" . $attributes[$at][0] . ")";
                        }
                        // Add attributes themselves as well, for later use
                        $simpleattrs['saml'] = $attributes;
                        //	echo "<pre>"; var_dump($simpleattrs);
                        ksort($simpleattrs);
                        return $simpleattrs;
                    }
                }
            }
        }
    }
    return false;
}
开发者ID:GEANT,项目名称:CORE,代码行数:32,代码来源:functions.php

示例4: beforeProcess

 public function beforeProcess(&$action)
 {
     if (CopixConfig::get('conf_Saml_actif') != 1) {
         return;
     }
     require_once COPIX_UTILS_PATH . '../../simplesamlphp/lib/_autoload.php';
     $asId = 'iconito-sql';
     if (CopixConfig::exists('default|conf_Saml_authSource') && CopixConfig::get('default|conf_Saml_authSource')) {
         $asId = CopixConfig::get('default|conf_Saml_authSource');
     }
     $as = new SimpleSAML_Auth_Simple($asId);
     $ppo->user = _currentUser();
     if ($as->isAuthenticated() && !$ppo->user->isConnected()) {
         $attributes = $as->getAttributes();
         $uidAttribute = 'login_dbuser';
         if (CopixConfig::exists('default|conf_Saml_uidAttribute') && CopixConfig::get('default|conf_Saml_uidAttribute')) {
             $uidAttribute = CopixConfig::get('default|conf_Saml_uidAttribute');
         }
         $ppo->saml_user = null;
         if (isset($attributes[$uidAttribute]) && isset($attributes[$uidAttribute][0])) {
             $ppo->saml_user = $attributes[$uidAttribute][0];
         }
         if ($ppo->saml_user) {
             $ppo->iconito_user = Kernel::getUserInfo("LOGIN", $ppo->saml_user);
             if ($ppo->iconito_user['login']) {
                 _currentUser()->login(array('login' => $ppo->iconito_user['login'], 'assistance' => true));
                 $url_return = CopixUrl::get('kernel||doSelectHome');
                 // $url_return = CopixUrl::get ('assistance||users');
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return);
             } else {
                 $ppo->cas_error = 'no-iconito-user';
                 return _arPpo($ppo, 'cas.tpl');
             }
         }
     }
     if (!$as->isAuthenticated() && $ppo->user->isConnected()) {
         $ppo->user = _currentUser();
         if ($ppo->user->isConnected()) {
             CopixAuth::getCurrentUser()->logout(array());
             CopixEventNotifier::notify('logout', array('login' => CopixAuth::getCurrentUser()->getLogin()));
             CopixAuth::destroyCurrentUser();
             CopixSession::destroyNamespace('default');
         }
     }
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:45,代码来源:auth_saml.plugin.php

示例5: 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

示例6: logout

 public function logout()
 {
     //check for application session and invalidate
     if (Auth::check()) {
         Auth::logout();
     }
     //check for sso session and invalidate
     $as = new \SimpleSAML_Auth_Simple('default-sp');
     if ($as->isAuthenticated()) {
         $as->logout();
     }
     //redirect to home
     return Redirect::Action('mainController@index');
 }
开发者ID:pkoro,项目名称:webconf-portal,代码行数:14,代码来源:mainController.php

示例7: authenticate

 public function authenticate()
 {
     try {
         $as = new \SimpleSAML_Auth_Simple($this->_domain);
         $globalConfig = \SimpleSAML_Configuration::getInstance();
         //$globalConfig::setConfigDir(G_CONFIGDIR.'saml/');
         $as->requireAuth();
         if ($as->isAuthenticated()) {
             $attributes = $as->getAttributes();
             if (!array_key_exists($this->_sso_settings['saml_email'], $attributes)) {
                 // 					TemplateController::setMessage(("A valid email is needed for account related communication").". ".("Check that the %s attribute (%s) defined in your configuration is correct",("Email"),$this->_sso_settings['saml_email']), 'error');
                 $this->ssoLogout();
             } elseif (!array_key_exists($this->_sso_settings['saml_first_name'], $attributes)) {
                 // 					TemplateController::setMessage(("'%s' is required",("First name")).". ".("Check that the %s attribute (%s) defined in your configuration is correct",("First name"),$this->_sso_settings['saml_first_name']), 'error');
                 $this->ssoLogout();
             } elseif (!array_key_exists($this->_sso_settings['saml_last_name'], $attributes)) {
                 // 					TemplateController::setMessage(("'%s' is required",("Last name")).". ".("Check that the %s attribute (%s) defined in your configuration is correct",("Last name"),$this->_sso_settings['saml_last_name']), 'error');
                 $this->ssoLogout();
             } else {
                 if (trim($attributes[$this->_sso_settings['saml_email']][0]) == '') {
                     $attributes[$this->_sso_settings['saml_email']][0] = " ";
                     // 						TemplateController::setMessage(("A valid email is needed for account related communication"), 'error');
                 }
                 if (trim($attributes[$this->_sso_settings['saml_first_name']][0]) == '' && trim($attributes[$this->_sso_settings['saml_last_name']][0]) == '') {
                     $attributes[$this->_sso_settings['saml_first_name']][0] = ' ';
                     $attributes[$this->_sso_settings['saml_last_name']][0] = ' ';
                 } else {
                     if (trim($attributes[$this->_sso_settings['saml_first_name']][0]) == '') {
                         $attributes[$this->_sso_settings['saml_first_name']][0] = $attributes[$this->_sso_settings['saml_last_name']][0];
                     }
                     if (trim($attributes[$this->_sso_settings['saml_last_name']][0]) == '') {
                         $attributes[$this->_sso_settings['saml_last_name']][0] = $attributes[$this->_sso_settings['saml_first_name']][0];
                     }
                 }
                 $this->_login($attributes);
                 //pr($attributes);exit;
                 //echo "redirect now";exit;
                 //\SimpleSAML_Utilities::postRedirect("https://index.php", $attributes);
             }
         }
     } catch (\SimpleSAML_Error_Error $e) {
         $this->_samlErrorHandler($e);
     } catch (\Exception $e) {
         handleNormalFlowExceptions($e);
     }
     return $this;
 }
开发者ID:jiangjunt,项目名称:efront_open_source,代码行数:47,代码来源:saml.class.php

示例8: __construct

 public function __construct()
 {
     //	Obligatoire
     parent::__construct();
     $this->data = array();
     // System FED Oxylane
     if (FEDACTIVE) {
         require __DIR__ . '/../simplesaml/lib/_autoload.php';
         $as = new SimpleSAML_Auth_Simple('Oxylane-sp');
         $isAuth = $as->isAuthenticated();
         $url = $as->getLoginURL();
         if (!$isAuth) {
             //$url = $as->getLoginURL();
             //echo '<p>You are not authenticated. <a href="' . htmlspecialchars($url) . '">Log in</a>.</p>';
             $as->requireAuth();
         } else {
             //$url = $as->getLogoutURL();
             //echo '<p>You are currently authenticated. <a href="' . htmlspecialchars($url) . '">Log out</a>.</p>';
             $attributes = $as->getAttributes();
             $uid = $attributes['uid'][0];
             $this->data['fed']['0'] = $uid;
             $this->data['fed']['1'] = $attributes['cn'][0];
             $this->data['fed']['2'] = $attributes['mail'][0];
             $this->load->model('admins_model', 'am');
             $admins = $this->am->getAll();
             if (!$this->in_array_column($uid, $admins)) {
                 echo "Utilisateur non autoris&eacute;s";
                 redirect('welcome', 'refresh');
             }
         }
     } else {
         $this->data['fed']['0'] = "ID";
         $this->data['fed']['1'] = "NOM";
         $this->data['fed']['2'] = "MAIL";
     }
     // END System FED Oxylane
     //	Chargement des ressources pour tout le contrôleur
     $this->load->database();
     $this->load->helper('form');
     $this->load->library('form_validation');
     $this->load->model('pages_model', 'pm');
     $this->load->model('chaines_model', 'cm');
     $this->load->model('groupes_model', 'gm');
     $this->load->model('logs_model', 'lm');
 }
开发者ID:keyanmca,项目名称:webtv,代码行数:45,代码来源:superadmin.php

示例9: isAuthenticated

 public static function isAuthenticated()
 {
     require_once SamlAuth::LIB_AUTOLOAD;
     $source = null;
     $config = SimpleSAML_Configuration::getInstance();
     $t = new SimpleSAML_XHTML_Template($config, 'core:authsource_list.tpl.php');
     $t->data['sources'] = SimpleSAML_Auth_Source::getSourcesMatch('-sp');
     foreach ($t->data['sources'] as &$_source) {
         $as = new SimpleSAML_Auth_Simple($_source);
         if ($as->isAuthenticated()) {
             $source = $as;
             break;
         }
     }
     if ($source === null) {
         return false;
     }
     return $source;
 }
开发者ID:IASA-GR,项目名称:appdb-core,代码行数:19,代码来源:samlauth.php

示例10: 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);
     }
     $as = new \SimpleSAML_Auth_Simple($authenticationType);
     if (!$as->isAuthenticated()) {
         throw new AuthenticationException("Authsource '{$authenticationType}' is invalid");
     }
     /** @var string $userIdAttributeName */
     $userIdAttributeName = $this->config->getValue('useridattr', 'eduPersonPrincipalName');
     // Check if userid exists
     $attributes = $as->getAttributes();
     if (!isset($attributes[$userIdAttributeName])) {
         throw new AuthenticationException("Attribute '{$userIdAttributeName}' with User ID is missing.");
     }
     return $this->getTokenForUsername($attributes[$userIdAttributeName][0]);
 }
开发者ID:janus-ssp,项目名称:janus,代码行数:20,代码来源:SspProvider.php

示例11: mostrarBotonLogin

 function mostrarBotonLogin()
 {
     //configuración de simplesaml para autenticación SSO (single sign ON)
     $saml_lib_path = '/var/simplesamlphp/lib/_autoload.php';
     require_once $saml_lib_path;
     $aplication_base_url = $this->host . $this->site;
     $source = 'SP_SNIES';
     # Fuente de autenticación definida en el authsources del SP
     $as = new SimpleSAML_Auth_Simple($source);
     # Se pasa como parametro la fuente de autenticación
     //var_dump($as->isAuthenticated());
     if (!$as->isAuthenticated()) {
         $this->formulario();
     } else {
         //$valorCodificado = "action=loginSso";
         $valorCodificado = "&pagina=listadoVariablesSnies";
         //$esteBloque=$this->miConfigurador->getVariableConfiguracion ( 'esteBloque' );
         //$valorCodificado .= "&bloque=" . $esteBloque ['nombre'];
         //$valorCodificado .= "&bloqueGrupo=" . $esteBloque ["grupo"];
         $valorCodificado = $this->miConfigurador->fabricaConexiones->crypto->codificar($valorCodificado);
         //Mostrar enlace
         //Rescatar el parámetro enlace desde los datos de configuraión en la base de datos
         $variable = $this->miConfigurador->getVariableConfiguracion("enlace");
         $miEnlace = $this->host . $this->site . '/index.php?' . $variable . '=' . $valorCodificado;
         header("Location: " . $miEnlace);
         //var_dump($miEnlace);
         $attributes = $as->getAttributes();
         if (empty($attributes)) {
             echo 'No se obtuvieron atributos del usuario';
         } else {
             echo '<table class="table table-bordered table-striped">';
             foreach ($attributes as $key => $values) {
                 echo '<tr><td>' . $key . '</td><td>';
                 echo implode('<br>', $values);
                 echo '</td></tr>';
             }
             echo '</table>';
         }
         //echo '<p><a class="btn" href="logout.php">Cerrar sesión</a></p>';
     }
 }
开发者ID:udistrital,项目名称:zoe,代码行数:41,代码来源:formLoginSso.php

示例12: processRequest

 /**
  * Process a request.
  *
  * This function never returns.
  *
  * @param Auth_OpenID_Request $request  The request we are processing.
  */
 public function processRequest(array $state)
 {
     assert('isset($state["request"])');
     SimpleSAML_Utilities::maskErrors(E_NOTICE | E_STRICT);
     $request = $state['request'];
     if (!$this->authSource->isAuthenticated()) {
         if ($request->immediate) {
             /* Not logged in, and we cannot show a login form. */
             $this->sendResponse($request->answer(FALSE));
         }
         $resumeURL = $this->getStateURL('resume.php', $state);
         $this->authSource->requireAuth(array('ReturnTo' => $resumeURL));
     }
     $identity = $this->getIdentity();
     assert('$identity !== FALSE');
     /* Should always be logged in here. */
     if (!$request->idSelect() && $identity !== $request->identity) {
         /* The identity in the request doesn't match the one of the logged in user. */
         throw new SimpleSAML_Error_Exception('Logged in as different user than the one requested.');
     }
     if ($this->isTrusted($identity, $request->trust_root)) {
         $trusted = TRUE;
     } elseif (isset($state['TrustResponse'])) {
         $trusted = (bool) $state['TrustResponse'];
     } else {
         if ($request->immediate) {
             /* Not trusted, and we cannot show a trust-form. */
             $this->sendResponse($request->answer(FALSE));
         }
         $trustURL = $this->getStateURL('trust.php', $state);
         SimpleSAML_Utilities::redirect($trustURL);
     }
     if (!$trusted) {
         /* The user doesn't trust this site. */
         $this->sendResponse($request->answer(FALSE));
     }
     /* The user is authenticated, and trusts this site. */
     $this->sendResponse($request->answer(TRUE, NULL, $identity));
 }
开发者ID:filonuse,项目名称:fedlab,代码行数:46,代码来源:Server.php

示例13: execute

 /**
  * Executes this filter.
  *
  * @param sfFilterChain $filterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     // disable security on login and secure actions
     /*
         if (
           (sfConfig::get('sf_login_module') == $this->context->getModuleName()) && (sfConfig::get('sf_login_action') == $this->context->getActionName())
           ||
           (sfConfig::get('sf_secure_module') == $this->context->getModuleName()) && (sfConfig::get('sf_secure_action') == $this->context->getActionName())
         )
         {
           $filterChain->execute();
     
           return;
         }
     */
     if ($this->context->getUser()->isAuthenticated()) {
         $as = new SimpleSAML_Auth_Simple('default-sp');
         if (!$as->isAuthenticated()) {
             $this->context->getUser()->setAuthenticated(FALSE);
         }
     }
     // the user has access, continue
     $filterChain->execute();
 }
开发者ID:br00k,项目名称:yavom,代码行数:29,代码来源:sfSAMLSecurityFilter.class.php

示例14: isAuthenticated

 /**
  * Is the current user authenticated?
  *
  * @return bool  TRUE if the user is authenticated, FALSE if not.
  */
 public function isAuthenticated()
 {
     return $this->authSource->isAuthenticated();
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:9,代码来源:IdP.php

示例15: Exception

 * @author     Jacob Christiansen <jach@wayf.dk>
 * @copyright  2009 Jacob Christiansen
 * @license    http://www.opensource.org/licenses/mit-license.php MIT License
 * @link       http://github.com/janus-ssp/janus/
 * @since      File available since Release 1.5.1
 */
require __DIR__ . '/_includes.php';
// Initial setup
$config = SimpleSAML_Configuration::getInstance();
$janus_config = sspmod_janus_DiContainer::getInstance()->getConfig();
$authsource = $janus_config->getValue('auth', 'login-admin');
$useridattr = $janus_config->getValue('useridattr', 'eduPersonPrincipalName');
$et = new SimpleSAML_XHTML_Template($config, 'janus:editentity.php', 'janus:editentity');
$as = new SimpleSAML_Auth_Simple($authsource);
// Validate user
if ($as->isAuthenticated()) {
    $attributes = $as->getAttributes();
    // Check if userid exists
    if (!isset($attributes[$useridattr])) {
        throw new Exception('User ID is missing');
    }
    $userid = $attributes[$useridattr][0];
} else {
    echo $et->t('error_no_access');
    exit;
}
// Get Entity controller
$mcontroller = sspmod_janus_DiContainer::getInstance()->getEntityController();
// Get the user
$user = new sspmod_janus_User();
$user->setUserid($userid);
开发者ID:janus-ssp,项目名称:janus,代码行数:31,代码来源:history.php


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