示例#1
0
 /**
  * Collect the id of the configured attributes we allow in an ARP.
  *
  * @return array<string>
  * @throws Exception
  */
 private function getAllowedArpAttributes()
 {
     $configured_attributes = $this->_config->getValue('attributes');
     $arp_attributes = array();
     foreach ($configured_attributes as $label => $config) {
         $arp_attributes[] = $config['name'];
     }
     return $arp_attributes;
 }
示例#2
0
 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]);
 }
示例#3
0
function addArpConfiguration(SimpleSAML_XHTML_Template $et, ConfigProxy $janus_config)
{
    $arp_attributes = array();
    $old_arp_attributes = $janus_config->getValue('attributes');
    foreach ($old_arp_attributes as $label => $arp_attribute) {
        if (is_array($arp_attribute)) {
            $arp_attributes[$label] = $arp_attribute;
        } else {
            $arp_attributes[$arp_attribute] = array('name' => $arp_attribute);
        }
    }
    $et->data['arp_attributes_configuration'] = $arp_attributes;
}
 /**
  * @return string
  * @throws RuntimeException
  */
 public function getLoggedInUsername()
 {
     if (static::$allowNoAuthenticatedUser) {
         return null;
     }
     /** @var string $authenticationType */
     $authenticationType = $this->config->getValue('auth', 'login-admin');
     if (php_sapi_name() === 'cli') {
         return $authenticationType;
     }
     $session = SimpleSAML_Session::getInstance();
     if (!$session->isValid($authenticationType)) {
         throw new RuntimeException("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 RuntimeException("Attribute '{$userIdAttributeName}' with User ID is missing.");
     }
     return $attributes[$userIdAttributeName][0];
 }
示例#5
0
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;
}
示例#6
0
 /**
  * Loads deployable workflow states from config
  *
  * @return array $deployableStateList
  */
 private function _loadDeployableWorkflowStates()
 {
     static $deployableStateList = array();
     if (empty($deployableStateList)) {
         $stateList = $this->_config->getValue('workflowstates');
         foreach ($stateList as $stateName => $stateConfig) {
             $isDeployable = array_key_exists('isDeployable', $stateConfig) && true === $stateConfig['isDeployable'];
             if ($isDeployable) {
                 $deployableStateList[] = $stateName;
             }
         }
         // Backwards compatibility, if no states are marked as deployable, all states are used
         $noStatesMarkedAsDeployable = empty($deployableStateList);
         if ($noStatesMarkedAsDeployable) {
             $deployableStateList = array_keys($stateList);
         }
     }
     return $deployableStateList;
 }
示例#7
0
 /**
  * instantiate the postman
  *
  * @since Method available since Release 1.2.0
  */
 public function __construct()
 {
     $this->_config = sspmod_janus_DiContainer::getInstance()->getConfig();
     $this->_paginate = $this->_config->getValue('dashboard.inbox.paginate_by', 20);
 }