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


PHP SimpleSAML_Utilities::isAdmin方法代码示例

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


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

示例1: 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_Utilities::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_Utilities::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:shirlei,项目名称:simplesaml,代码行数:60,代码来源:AccessCheck.php

示例2: array

<?php

/* Load simpleSAMLphp, configuration */
$config = SimpleSAML_Configuration::getInstance();
$session = SimpleSAML_Session::getInstance();
/* Check if valid local session exists.. */
if ($config->getBoolean('admin.protectindexpage', false)) {
    SimpleSAML_Utilities::requireAdmin();
}
$loginurl = SimpleSAML_Utilities::getAdminLoginURL();
$isadmin = SimpleSAML_Utilities::isAdmin();
$warnings = array();
if (!SimpleSAML_Utilities::isHTTPS()) {
    $warnings[] = '{core:frontpage:warnings_https}';
}
if ($config->getValue('secretsalt') === 'defaultsecretsalt') {
    $warnings[] = '{core:frontpage:warnings_secretsalt}';
}
if (extension_loaded('suhosin')) {
    $suhosinLength = ini_get('suhosin.get.max_value_length');
    if (empty($suhosinLength) || (int) $suhosinLength < 2048) {
        $warnings[] = '{core:frontpage:warnings_suhosin_url_length}';
    }
}
$links = array();
$links_welcome = array();
$links_config = array();
$links_auth = array();
$links_federation = array();
$links_config[] = array('href' => SimpleSAML_Utilities::getBaseURL() . 'example-simple/hostnames.php?dummy=1', 'text' => '{core:frontpage:link_diagnostics}');
$links_config[] = array('href' => SimpleSAML_Utilities::getBaseURL() . 'admin/phpinfo.php', 'text' => '{core:frontpage:link_phpinfo}');
开发者ID:danielkjfrog,项目名称:docker,代码行数:31,代码来源:frontpage_config.php

示例3: SimpleSAML_Error_Exception

$config = SimpleSAML_Configuration::getInstance();
$statconfig = SimpleSAML_Configuration::getConfig('module_statistics.php');
$session = SimpleSAML_Session::getInstance();
/**
 * AUTHENTICATION and Authorization for access to the statistics.
 */
$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) {
    if (SimpleSAML_Utilities::isAdmin()) {
        // User logged in as admin. OK.
        SimpleSAML_Logger::debug('Statistics auth - logged in as admin, access granted');
    } elseif (isset($authsource) && $session->isValid($authsource)) {
        // User logged in with auth source.
        SimpleSAML_Logger::debug('Statistics auth - valid login with auth source [' . $authsource . ']');
        // Retrieving attributes
        $attributes = $session->getAttributes();
        $allow = FALSE;
        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)) {
开发者ID:hukumonline,项目名称:yii,代码行数:31,代码来源:showstats.php

示例4: array

    $metaBuilder->addMetadataSP20($metaArray);
    $metaBuilder->addContact('technical', array('emailAddress' => $config->getString('technicalcontact_email', NULL), 'name' => $config->getString('technicalcontact_name', NULL)));
    $metaxml = $metaBuilder->getEntityDescriptorText();
    /* Sign the metadata if enabled. */
    $metaxml = SimpleSAML_Metadata_Signer::sign($metaxml, $spmeta, 'SAML 2 SP');
    /*
     * Generate list of IdPs that you can send metadata to.
     */
    $idplist = $metadata->getList('saml20-idp-remote');
    $idpsend = array();
    foreach ($idplist as $entityid => $mentry) {
        if (array_key_exists('send_metadata_email', $mentry)) {
            $idpsend[$entityid] = $mentry;
        }
    }
    $adminok = SimpleSAML_Utilities::isAdmin();
    $adminlogin = SimpleSAML_Utilities::getAdminLoginURL(SimpleSAML_Utilities::addURLParameter(SimpleSAML_Utilities::selfURLNoQuery(), array('output' => 'xhtml')));
    $sentok = FALSE;
    /*
     * Send metadata to Identity Provider, if the user filled submitted the form
     */
    if (array_key_exists('sendtoidp', $_POST)) {
        if (!array_key_exists($_POST['sendtoidp'], $idpsend)) {
            throw new Exception('Entity ID ' . $_POST['sendtoidp'] . ' not found in metadata. Cannot send metadata to this IdP.');
        }
        $emailadr = $idpsend[$_POST['sendtoidp']]['send_metadata_email'];
        $from = $_POST['email'];
        $message = '<h1>simpleSAMLphp SAML 2.0 Service Provider Metadata</h1>

<p>Metadata was sent to you from a simpleSAMLphp SAML 2.0 Service Provider. The service provider requests to connect to the following Identity Provider: 
	<ul>
开发者ID:hukumonline,项目名称:yii,代码行数:31,代码来源:metadata.php


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