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


PHP SimpleSAML_Auth_Simple类代码示例

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


在下文中一共展示了SimpleSAML_Auth_Simple类的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: executeIndex

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->getParameter('sf_culture')) {
         $ssaml = new SimpleSAML_Auth_Simple('default-sp');
         $attributes = $ssaml->getAttributes();
         if ($this->getUser()->isFirstRequest()) {
             if (array_key_exists('preferredLanguage', $attributes)) {
                 $culture = $attributes['preferredLanguage'];
                 if ($culture != 'hu' && $culture != 'en') {
                     $culture = $request->getPreferredCulture(array('en', 'hu'));
                 }
             } else {
                 $culture = $request->getPreferredCulture(array('en', 'hu'));
             }
             $this->getUser()->setCulture($culture);
             $this->getUser()->isFirstRequest(false);
         } else {
             $culture = $this->getUser()->getCulture();
         }
         $this->redirect('localized_homepage');
     }
     $p = Doctrine::getTable('Principal')->findOneByFedid($this->getUser()->getUsername());
     if ($p) {
         $oos = $p->getOrganization();
         $ros = $p->getRelatedOrganizations(TRUE);
     } else {
         $p = new Principal();
         $p->setFedid($this->getUser()->getUsername());
         $p->save();
     }
     $this->oos = $oos;
     $this->ros = $ros;
 }
开发者ID:br00k,项目名称:yavom,代码行数:38,代码来源:actions.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: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             //return redirect()->guest('auth/login')
             //tsipizic for SAML
             //login user and get attributes
             $as = new \SimpleSAML_Auth_Simple('default-sp');
             $as->requireAuth();
             $attributes = $as->getAttributes();
             //create user if he does not exist and log him in
             $mail = $attributes['mail'][0];
             $db_user = User::where('mail', $mail)->first();
             if ($db_user) {
                 Auth::login($db_user);
             } else {
                 $user = new User();
                 $user->mail = $mail;
                 $user->save();
                 Auth::login($user);
             }
         }
     }
     return $next($request);
 }
开发者ID:pkoro,项目名称:webconf-portal,代码行数:34,代码来源:Authenticate.php

示例5: authenticate

 /**
  * Performs an authentication attempt using SimpleSAMLphp
  *
  * @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     require_once LIBRARY_PATH . '/simplesamlphp/lib/_autoload.php';
     $as = new SimpleSAML_Auth_Simple('default-sp');
     $as->requireAuth();
     // If SimpleSAMLphp didn't stop it, then the user is logged in.
     return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $as->getAttributes(), array("Authentication Successful"));
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:14,代码来源:Saml.php

示例6: checkAccess

 /**
  * Check that the user has access to the statistics.
  *
  * If the user doesn't have access, send the user to the login page.
  */
 public static function checkAccess(SimpleSAML_Configuration $statconfig)
 {
     $protected = $statconfig->getBoolean('protected', FALSE);
     $authsource = $statconfig->getString('auth', NULL);
     $allowedusers = $statconfig->getValue('allowedUsers', NULL);
     $useridattr = $statconfig->getString('useridattr', 'eduPersonPrincipalName');
     $acl = $statconfig->getValue('acl', NULL);
     if ($acl !== NULL && !is_string($acl) && !is_array($acl)) {
         throw new SimpleSAML_Error_Exception('Invalid value for \'acl\'-option. Should be an array or a string.');
     }
     if (!$protected) {
         return;
     }
     if (SimpleSAML\Utils\Auth::isAdmin()) {
         // User logged in as admin. OK.
         SimpleSAML_Logger::debug('Statistics auth - logged in as admin, access granted');
         return;
     }
     if (!isset($authsource)) {
         // If authsource is not defined, init admin login.
         SimpleSAML\Utils\Auth::requireAdmin();
     }
     /* We are using an authsource for login. */
     $as = new SimpleSAML_Auth_Simple($authsource);
     $as->requireAuth();
     // User logged in with auth source.
     SimpleSAML_Logger::debug('Statistics auth - valid login with auth source [' . $authsource . ']');
     // Retrieving attributes
     $attributes = $as->getAttributes();
     if (!empty($allowedusers)) {
         // Check if userid exists
         if (!isset($attributes[$useridattr][0])) {
             throw new Exception('User ID is missing');
         }
         // Check if userid is allowed access..
         if (in_array($attributes[$useridattr][0], $allowedusers)) {
             SimpleSAML_Logger::debug('Statistics auth - User granted access by user ID [' . $attributes[$useridattr][0] . ']');
             return;
         }
         SimpleSAML_Logger::debug('Statistics auth - User denied access by user ID [' . $attributes[$useridattr][0] . ']');
     } else {
         SimpleSAML_Logger::debug('Statistics auth - no allowedUsers list.');
     }
     if (!is_null($acl)) {
         $acl = new sspmod_core_ACL($acl);
         if ($acl->allows($attributes)) {
             SimpleSAML_Logger::debug('Statistics auth - allowed access by ACL.');
             return;
         }
         SimpleSAML_Logger::debug('Statistics auth - denied access by ACL.');
     } else {
         SimpleSAML_Logger::debug('Statistics auth - no ACL configured.');
     }
     throw new SimpleSAML_Error_Exception('Access denied to the current user.');
 }
开发者ID:tractorcow,项目名称:simplesamlphp,代码行数:60,代码来源:AccessCheck.php

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

示例8: persistNewAccessToken

 /**
  * @inheritDoc
  */
 public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity)
 {
     $as = $this->config->getString('auth');
     $auth = new \SimpleSAML_Auth_Simple($as);
     // We should be authenticated so this returns the session user attributes (or [] if not)
     $attributes = $auth->getAttributes();
     $scopes = [];
     foreach ($accessTokenEntity->getScopes() as $scope) {
         $scopes[] = $scope->getIdentifier();
     }
     $this->conn->insert($this->getTableName(), ['id' => $accessTokenEntity->getIdentifier(), 'scopes' => $scopes, 'attributes' => $attributes, 'expires_at' => $accessTokenEntity->getExpiryDateTime(), 'user_id' => $accessTokenEntity->getUserIdentifier(), 'client_id' => $accessTokenEntity->getClient()->getIdentifier()], ['string', 'json_array', 'json_array', 'datetime', 'string', 'string']);
 }
开发者ID:sgomez,项目名称:simplesamlphp-module-oauth2,代码行数:15,代码来源:AccessTokenRepository.php

示例9: procesarFormulario

 function procesarFormulario()
 {
     $saml_lib_path = '/var/simplesamlphp/lib/_autoload.php';
     require_once $saml_lib_path;
     // $aplication_base_url = 'http://10.20.0.38/splocal/';
     $aplication_base_url = $this->host . $this->site . '/';
     $source = 'SPcrono';
     // Fuente de autenticación definida en el authsources del SP
     $auth = new SimpleSAML_Auth_Simple($source);
     // Se pasa como parametro la fuente de autenticación
     $auth->logout($aplication_base_url . 'index.php');
     return true;
 }
开发者ID:udistrital,项目名称:zoe,代码行数:13,代码来源:Logout.php

示例10: requireAdmin

 /**
  * Require admin access to the current page.
  *
  * This is a helper function for limiting a page to those with administrative access. It will redirect the user to
  * a login page if the current user doesn't have admin access.
  *
  * @return void This function will only return if the user is admin.
  * @throws \SimpleSAML_Error_Exception If no "admin" authentication source was configured.
  *
  * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
  * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
  */
 public static function requireAdmin()
 {
     if (self::isAdmin()) {
         return;
     }
     // not authenticated as admin user, start authentication
     if (\SimpleSAML_Auth_Source::getById('admin') !== null) {
         $as = new \SimpleSAML_Auth_Simple('admin');
         $as->login();
     } else {
         throw new \SimpleSAML_Error_Exception('Cannot find "admin" auth source, and admin privileges are required.');
     }
 }
开发者ID:PitcherAG,项目名称:simplesamlphp,代码行数:25,代码来源:Auth.php

示例11: downloadAction

 public function downloadAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout->disableLayout();
     $filename = APPLICATION_ROOT . '/public_html/files/' . $this->_getParam('filename');
     $filename = realpath($filename);
     try {
         $file = new SxCms_File($filename);
         $data = $file->getCleanFile();
         $identity = Zend_Auth::getInstance()->getIdentity();
         if (!$file->isAllowed($identity)) {
             $this->_helper->redirector->setExit(true)->gotoSimple('unauthorized', 'index');
             return;
         }
         if ($file->isApb()) {
             $as = new SimpleSAML_Auth_Simple('klavsts');
             $attributes = $as->getAttributes();
             if (!$attributes) {
                 $this->_forward('unauthorized', 'index', null, array('url' => $this->view->url()));
                 return;
             }
             $attributes = $attributes['urn:klav:docmanager'];
             $filecheck = new SxCms_Filesystem($file->getPath());
             $filecheck->setApb($attributes);
             if (!$filecheck->isAllowed()) {
                 $this->_helper->redirector->setExit(true)->gotoSimple('unauthorized', 'index');
                 return;
             }
         }
         // workaround for when PECL class finfo is not installed
         $mimeType = 'application/octet-stream';
         if (@class_exists('finfo')) {
             $finfo = new finfo(FILEINFO_MIME);
             $mimeType = $finfo->file($filename);
         }
         // mimetype "unknown", let's figure it out by filename extension
         if ($mimeType == 'application/octet-stream') {
             $ext = strtolower(end(explode('.', $filename)));
             $types = simplexml_load_file(APPLICATION_PATH . '/var/mime-types.xml');
             $result = $types->xpath('//mime-types/mime-type/ext[. ="' . $ext . '"]/..');
             $result = $result[0]->attributes();
             $result = (string) $result['name'];
             $mimeType = $result;
         }
         $size = mb_strlen($data);
         $this->getResponse()->setHeader('Content-Type', $mimeType)->setHeader('Content-Length', $size);
         echo $data;
     } catch (Exception $e) {
         throw new Zend_Controller_Action_Exception('File not found', 404);
     }
 }
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:51,代码来源:FileController.php

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

示例13: procesarFormulario

 function procesarFormulario()
 {
     $saml_lib_path = '/var/simplesamlphp/lib/_autoload.php';
     require_once $saml_lib_path;
     // $aplication_base_url = 'http://10.20.0.38/splocal/';
     $aplication_base_url = $this->host . $this->site . '/';
     $source = 'SPcrono';
     // 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
     $login_params = array('ReturnTo' => $aplication_base_url . 'index.php');
     $as->requireAuth($login_params);
     $aaa = $as->getAttributes();
     return false;
 }
开发者ID:udistrital,项目名称:zoe,代码行数:15,代码来源:formProcessor.php

示例14: forward

 /**
  * Hook on the forward function to make sure we can logout on SimpleSAML
  *
  * @param string $hook         the name of the hook
  * @param string $type         the tpe of the hook
  * @param bool   $return_value the current url to forward to
  * @param array  $params       supplied params
  *
  * @return void
  */
 public static function forward($hook, $type, $return_value, $params)
 {
     global $SIMPLESAML_SOURCE;
     if (elgg_is_logged_in() || empty($SIMPLESAML_SOURCE)) {
         return;
     }
     // do we have a logout source
     try {
         $source = new \SimpleSAML_Auth_Simple($SIMPLESAML_SOURCE);
         // logout of the external source
         $source->logout(elgg_get_site_url());
     } catch (Exception $e) {
         // do nothing
     }
 }
开发者ID:coldtrick,项目名称:simplesaml,代码行数:25,代码来源:Logout.php

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


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