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


PHP SimpleSAML_Auth_Source::getSourcesMatch方法代码示例

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


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

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

示例2: postconnectAction

 public function postconnectAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $referer = trim($this->session->connectreferer);
     if (trim($referer) === "") {
         $referer = $_SERVER["HTTP_REFERER"];
         $this->session->connectreferer = $referer;
     }
     if (trim($referer) === "") {
         $referer = "https://" . $_SERVER["HTTP_HOST"];
     }
     //check if user is loggedin
     if (isset($this->session->userid) === false || is_numeric($this->session->userid) === false || intval($this->session->userid) <= 0) {
         header("Location: " . $referer);
         return;
     }
     //Check if source is given
     $source = trim($this->_getParam("source"));
     if ($source == "") {
         header("Location: https://" . $_SERVER["HTTP_HOST"]);
         return;
     }
     $this->session->connectdaccountsource = $source;
     $authsource = str_replace("-sp", "", strtolower(trim($source)));
     $connectedsource = str_replace("-sp", "-connect", strtolower(trim($source)));
     require_once SamlAuth::LIB_AUTOLOAD;
     //Initialize SAML
     $config = SimpleSAML_Configuration::getInstance();
     $t = new SimpleSAML_XHTML_Template($config, 'core:authsource_list.tpl.php');
     $t->data['sources'] = SimpleSAML_Auth_Source::getSourcesMatch('-connect');
     if (!in_array($connectedsource, $t->data['sources'])) {
         header("Location: " . $referer);
         return;
     }
     //SAML Authentication new user account for connection
     $as = new SimpleSAML_Auth_Simple($connectedsource);
     $attributes = $as->getAttributes();
     $uid = $attributes['idp:uid'][0];
     if (trim($uid) == "") {
         $this->session->userError = array("title" => "New Account Connection", "message" => "Could not connect with new user account. Not enough information returned from account provider.");
         $this->_helper->redirector('postconnected');
         return;
     }
     //Check if user is already connected to the requested account
     //If true redirect the user to the previous location (referer)
     $uaccount = AccountConnect::isConnectedTo($this->session, $uid, $authsource);
     if ($uaccount !== false) {
         $this->_helper->redirector('postconnected');
         return;
     } else {
         //Check if this account is already connected to another profile
         $user = SamlAuth::getUserByAccountValues($uid, $authsource);
         if ($user !== null && $user->id != $this->session->userid) {
             $this->session->userError = array("title" => "Could not connect to " . str_replace("-", " ", $authsource) . " account", "message" => "The " . str_replace("-", " ", $authsource) . " account you tried to connect your profile to is already connected to another user profile.");
             $this->_helper->redirector('postconnected');
             return;
         }
     }
     //Build account name for user account
     $userFirstName = isset($attributes["idp:givenName"]) === true && count($attributes["idp:givenName"]) > 0 ? $attributes["idp:givenName"][0] : "";
     $userLastName = isset($attributes["idp:sn"]) === true && count($attributes["idp:givenName"]) > 0 ? $attributes["idp:sn"][0] : "";
     $userFullName = trim($userFirstName . " " . $userLastName);
     $idptrace = isset($attributes["idp:traceidp"]) === true && count($attributes["idp:traceidp"]) > 0 ? $attributes["idp:traceidp"] : array();
     if ($userFullName === "") {
         $userFullName = null;
     }
     //Do the account connection
     AccountConnect::connectAccountToProfile($this->session->userid, $uid, $authsource, $userFullName, $idptrace);
     //Update connected user accounts
     $this->session->currentUserAccounts = SamlAuth::getUserAccountsByUser($this->session->userid, true);
     //redirect to post connected action to logout connected account
     $this->_helper->redirector('postconnected');
 }
开发者ID:IASA-GR,项目名称:appdb-core,代码行数:74,代码来源:SamlController.php


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