ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
sspmod_core_Auth_Process_ScopeFromAttribute Class Reference

Retrieve a scope from a source attribute and add it as a virtual target attribute. More...

+ Inheritance diagram for sspmod_core_Auth_Process_ScopeFromAttribute:
+ Collaboration diagram for sspmod_core_Auth_Process_ScopeFromAttribute:

Public Member Functions

 __construct ($config, $reserved)
 Initialize this filter, parse configuration. More...
 
 process (&$request)
 Apply this filter. More...
 
- Public Member Functions inherited from SimpleSAML_Auth_ProcessingFilter
 __construct (&$config, $reserved)
 Constructor for a processing filter. More...
 
 process (&$request)
 Process a request. More...
 

Private Attributes

 $sourceAttribute
 
 $targetAttribute
 

Additional Inherited Members

- Data Fields inherited from SimpleSAML_Auth_ProcessingFilter
 $priority = 50
 Priority of this filter. More...
 

Detailed Description

Retrieve a scope from a source attribute and add it as a virtual target attribute.

For instance, add the following to $simplesamldir/config.php, entry authproc.sp

51 => array( 'class' => 'core:ScopeFromAttribute', 'sourceAttribute' => 'eduPersonPrincipalName', 'targetAttribute' => 'scope', ),

to add a virtual 'scope' attribute from the eduPersonPrincipalName attribute.

Definition at line 19 of file ScopeFromAttribute.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_core_Auth_Process_ScopeFromAttribute::__construct (   $config,
  $reserved 
)

Initialize this filter, parse configuration.

Parameters
array$configConfiguration information about this filter.
mixed$reservedFor future use.

Definition at line 39 of file ScopeFromAttribute.php.

References $config, and SimpleSAML_Configuration\loadFromArray().

39  {
40  parent::__construct($config, $reserved);
41  assert(is_array($config));
42 
44  $this->targetAttribute = $config->getString('targetAttribute');
45  $this->sourceAttribute = $config->getString('sourceAttribute');
46  } // end constructor
$config
Definition: bootstrap.php:15
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the call graph for this function:

Member Function Documentation

◆ process()

sspmod_core_Auth_Process_ScopeFromAttribute::process ( $request)

Apply this filter.

Parameters
array&$requestThe current request

Definition at line 54 of file ScopeFromAttribute.php.

References $attributes, $request, $sourceAttribute, $targetAttribute, SimpleSAML\Logger\debug(), and SimpleSAML\Logger\warning().

54  {
55  assert(is_array($request));
56  assert(array_key_exists('Attributes', $request));
57 
58  $attributes =& $request['Attributes'];
59 
60  if (!isset($attributes[$this->sourceAttribute])) {
61  return;
62  }
63 
64  // will not overwrite existing attribute
65  if (isset($attributes[$this->targetAttribute])) {
66  return;
67  }
68 
69  $sourceAttrVal = $attributes[$this->sourceAttribute][0];
70 
71  /* the last position of an @ is usually the beginning of the scope
72  * string */
73  $scopeIndex = strrpos($sourceAttrVal, '@');
74 
75  if ($scopeIndex !== FALSE) {
77  $scope = substr($sourceAttrVal, $scopeIndex+1);
79  SimpleSAML\Logger::debug('ScopeFromAttribute: Inserted new attribute ' .
80  $this->targetAttribute . ', with scope ' .
81  $scope);
82  } else {
83  SimpleSAML\Logger::warning('ScopeFromAttribute: The configured source attribute ' .
84  $this->sourceAttribute .
85  ' does not have a scope. Did not add attribute ' .
86  $this->targetAttribute . '.');
87  }
88  } /* end process */
foreach($paths as $path) $request
Definition: asyncclient.php:32
static debug($string)
Definition: Logger.php:211
static warning($string)
Definition: Logger.php:177
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
+ Here is the call graph for this function:

Field Documentation

◆ $sourceAttribute

sspmod_core_Auth_Process_ScopeFromAttribute::$sourceAttribute
private

Definition at line 25 of file ScopeFromAttribute.php.

Referenced by process().

◆ $targetAttribute

sspmod_core_Auth_Process_ScopeFromAttribute::$targetAttribute
private

Definition at line 31 of file ScopeFromAttribute.php.

Referenced by process().


The documentation for this class was generated from the following file: