ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
sspmod_core_Auth_Process_AttributeLimit Class Reference
+ Inheritance diagram for sspmod_core_Auth_Process_AttributeLimit:
+ Collaboration diagram for sspmod_core_Auth_Process_AttributeLimit:

Public Member Functions

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

Private Member Functions

 filterAttributeValues (array $values, array $allowedConfigValues)
 Perform the filtering of attributes. More...
 

Static Private Member Functions

static getSPIdPAllowed (array &$request)
 Get list of allowed from the SP/IdP config. More...
 

Private Attributes

 $allowedAttributes = array()
 List of attributes which this filter will allow through. More...
 
 $isDefault = false
 

Additional Inherited Members

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

Detailed Description

Definition at line 9 of file AttributeLimit.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_core_Auth_Process_AttributeLimit::__construct (   $config,
  $reserved 
)
Initialize this filter.

@param array $config  Configuration information about this filter.
@param mixed $reserved  For future use
Exceptions
SimpleSAML_Error_ExceptionIf invalid configuration is found.

Definition at line 32 of file AttributeLimit.php.

32 {
33 parent::__construct($config, $reserved);
34
35 assert(is_array($config));
36
37 foreach ($config as $index => $value) {
38 if ($index === 'default') {
39 $this->isDefault = (bool)$value;
40 } elseif (is_int($index)) {
41 if (!is_string($value)) {
42 throw new SimpleSAML_Error_Exception('AttributeLimit: Invalid attribute name: ' .
43 var_export($value, TRUE));
44 }
45 $this->allowedAttributes[] = $value;
46 } elseif (is_string($index)) {
47 if (!is_array($value)) {
48 throw new SimpleSAML_Error_Exception('AttributeLimit: Values for ' . var_export($index, TRUE) .
49 ' must be specified in an array.');
50 }
51 $this->allowedAttributes[$index] = $value;
52 } else {
53 throw new SimpleSAML_Error_Exception('AttributeLimit: Invalid option: ' . var_export($index, TRUE));
54 }
55 }
56 }
$config
Definition: bootstrap.php:15
$index
Definition: metadata.php:60

References $config, and $index.

Member Function Documentation

◆ filterAttributeValues()

sspmod_core_Auth_Process_AttributeLimit::filterAttributeValues ( array  $values,
array  $allowedConfigValues 
)
private

Perform the filtering of attributes.

Parameters
array$valuesThe current values for a given attribute
array$allowedConfigValuesThe allowed values, and possibly configuration options.
Returns
array The filtered values

Definition at line 133 of file AttributeLimit.php.

134 {
135 if (array_key_exists('regex', $allowedConfigValues) && $allowedConfigValues['regex'] === true) {
136 $matchedValues = array();
137 foreach ($allowedConfigValues as $option => $pattern) {
138 if (!is_int($option)) {
139 // Ignore any configuration options in $allowedConfig. e.g. regex=>true
140 continue;
141 }
142 foreach ($values as $index => $attributeValue) {
143 /* Suppress errors in preg_match since phpunit is set to fail on warnings, which
144 prevents us from testing with invalid regex.
145 */
146 $regexResult = @preg_match($pattern, $attributeValue);
147 if ($regexResult === false) {
148 \SimpleSAML\Logger::warning("Error processing regex '$pattern' on value '$attributeValue'");
149 break;
150 } elseif ($regexResult === 1) {
151 $matchedValues[] = $attributeValue;
152 // Remove matched value incase a subsequent regex also matches it.
153 unset($values[$index]);
154 }
155 }
156 }
157 return $matchedValues;
158 } elseif (array_key_exists('ignoreCase', $allowedConfigValues) && $allowedConfigValues['ignoreCase'] === true) {
159 unset($allowedConfigValues['ignoreCase']);
160 return array_uintersect($values, $allowedConfigValues, "strcasecmp");
161 }
162 // The not true values for these options shouldn't leak through to array_intersect
163 unset($allowedConfigValues['ignoreCase']);
164 unset($allowedConfigValues['regex']);
165
166 return array_intersect($values, $allowedConfigValues);
167 }
static warning($string)
Definition: Logger.php:177
$values

References $index, $values, and SimpleSAML\Logger\warning().

Referenced by process().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSPIdPAllowed()

static sspmod_core_Auth_Process_AttributeLimit::getSPIdPAllowed ( array &  $request)
staticprivate

Get list of allowed from the SP/IdP config.

Parameters
array&$requestThe current request.
Returns
array|NULL Array with attribute names, or NULL if no limit is placed.

Definition at line 65 of file AttributeLimit.php.

65 {
66
67 if (array_key_exists('attributes', $request['Destination'])) {
68 // SP Config
69 return $request['Destination']['attributes'];
70 }
71 if (array_key_exists('attributes', $request['Source'])) {
72 // IdP Config
73 return $request['Source']['attributes'];
74 }
75 return NULL;
76 }
foreach($paths as $path) $request
Definition: asyncclient.php:32

References $request.

Referenced by process().

+ Here is the caller graph for this function:

◆ process()

sspmod_core_Auth_Process_AttributeLimit::process ( $request)
Apply filter to remove attributes.

Removes all attributes which aren't one of the allowed attributes.

@param array &$request  The current request
Exceptions
SimpleSAML_Error_ExceptionIf invalid configuration is found.

Reimplemented from SimpleSAML_Auth_ProcessingFilter.

Definition at line 87 of file AttributeLimit.php.

87 {
88 assert(is_array($request));
89 assert(array_key_exists('Attributes', $request));
90
91 if ($this->isDefault) {
93 if ($allowedAttributes === NULL) {
95 }
96 } elseif (!empty($this->allowedAttributes)) {
98 } else {
100 if ($allowedAttributes === NULL) {
101 return; /* No limit on attributes. */
102 }
103 }
104
105 $attributes =& $request['Attributes'];
106
107 foreach ($attributes as $name => $values) {
108 if (!in_array($name, $allowedAttributes, TRUE)) {
109 // the attribute name is not in the array of allowed attributes
110 if (array_key_exists($name, $allowedAttributes)) {
111 // but it is an index of the array
112 if (!is_array($allowedAttributes[$name])) {
113 throw new SimpleSAML_Error_Exception('AttributeLimit: Values for ' . var_export($name, TRUE) .
114 ' must be specified in an array.');
115 }
117 if (!empty($attributes[$name])) {
118 continue;
119 }
120 }
121 unset($attributes[$name]);
122 }
123 }
124
125 }
static getSPIdPAllowed(array &$request)
Get list of allowed from the SP/IdP config.
$allowedAttributes
List of attributes which this filter will allow through.
filterAttributeValues(array $values, array $allowedConfigValues)
Perform the filtering of attributes.
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85

References $allowedAttributes, $attributes, $name, $request, $values, filterAttributeValues(), and getSPIdPAllowed().

+ Here is the call graph for this function:

Field Documentation

◆ $allowedAttributes

sspmod_core_Auth_Process_AttributeLimit::$allowedAttributes = array()
private

List of attributes which this filter will allow through.

Definition at line 14 of file AttributeLimit.php.

Referenced by process().

◆ $isDefault

sspmod_core_Auth_Process_AttributeLimit::$isDefault = false
private

Definition at line 22 of file AttributeLimit.php.


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