Skip to content
Snippets Groups Projects
Commit 499c6d72 authored by Thijs Kinkhorst's avatar Thijs Kinkhorst
Browse files

When attribute has multiple @, split on the first one.

eduPerson recommends: 'Multiple "@" signs are not recommended, but in any case,
the first occurrence of the "@" sign starting from the left is to be taken as
the delimiter between components. Thus, user identifier is to the left,
security domain to the right of the first "@".'

Closes #236
parent c1029a0a
No related branches found
No related tags found
No related merge requests found
...@@ -81,10 +81,9 @@ class ScopeFromAttribute extends Auth\ProcessingFilter ...@@ -81,10 +81,9 @@ class ScopeFromAttribute extends Auth\ProcessingFilter
$sourceAttrVal = $attributes[$this->sourceAttribute][0]; $sourceAttrVal = $attributes[$this->sourceAttribute][0];
/* the last position of an @ is usually the beginning of the /* Treat the first @ as usually the beginning of the scope
* scope string * string, as per eduPerson recommendation. */
*/ $scopeIndex = strpos($sourceAttrVal, '@');
$scopeIndex = strrpos($sourceAttrVal, '@');
if ($scopeIndex !== false) { if ($scopeIndex !== false) {
$attributes[$this->targetAttribute] = []; $attributes[$this->targetAttribute] = [];
......
...@@ -93,8 +93,7 @@ class ScopeFromAttributeTest extends TestCase ...@@ -93,8 +93,7 @@ class ScopeFromAttributeTest extends TestCase
/** /**
* When multiple @ signs in attribute, should use last one. * When multiple @ signs in attribute, should use first one.
* @return void
*/ */
public function testMultiAt(): void public function testMultiAt(): void
{ {
...@@ -109,7 +108,7 @@ class ScopeFromAttributeTest extends TestCase ...@@ -109,7 +108,7 @@ class ScopeFromAttributeTest extends TestCase
]; ];
$result = self::processFilter($config, $request); $result = self::processFilter($config, $request);
$attributes = $result['Attributes']; $attributes = $result['Attributes'];
$this->assertEquals($attributes['scope'], ['example.com']); $this->assertEquals($attributes['scope'], ['doe@example.com']);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment