Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
- Added possibility to use a callable for entityID parameter in PerunEntitlement(Extended)

## [v5.1.1]
#### Fixed
Expand Down
2 changes: 2 additions & 0 deletions config-templates/processFilterConfigurations-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Example how to enable/configure filter PerunEntitlement:
# forwarded entitlement are released by default
#'releaseForwardedEntitlement' => false, OPTIONAL
'forwardedEduPersonEntitlement' => 'eduPersonEntitlement',
#'entityID' => function($request){return empty($request["saml:RequesterID"]) ? $request["SPMetadata"]["entityid"] : $request["saml:RequesterID"][0];},
),
```

Expand All @@ -69,6 +70,7 @@ Example how to enable/configure filter PerunEntitlement:
# forwarded entitlement are released by default
#'releaseForwardedEntitlement' => false, OPTIONAL
'forwardedEduPersonEntitlement' => 'eduPersonEntitlement',
#'entityID' => function($request){return empty($request["saml:RequesterID"]) ? $request["SPMetadata"]["entityid"] : $request["saml:RequesterID"][0];},
),
```

Expand Down
9 changes: 8 additions & 1 deletion lib/Auth/Process/PerunEntitlement.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct($config, $reserved)
$this->groupNameAARC ? Configuration::REQUIRED_OPTION : ''
);

$this->entityId = $configuration->getString(self::ENTITY_ID, null);
$this->entityId = $configuration->getValue(self::ENTITY_ID, null);

$interface = $configuration->getValueValidate(
self::INTERFACE_PROPNAME,
Expand All @@ -82,6 +82,13 @@ public function process(&$request)

if ($this->entityId === null) {
$this->entityId = EntitlementUtils::getSpEntityId($request);
} elseif (is_callable($this->entityId)) {
$this->entityId = call_user_func($this->entityId, $request);
} elseif (!is_string($this->entityId)) {
throw new Exception(
'perun:PerunEntitlement: invalid configuration option entityID. ' .
'It must be a string or a callable.'
);
}

if (isset($request['perun']['groups'])) {
Expand Down
9 changes: 8 additions & 1 deletion lib/Auth/Process/PerunEntitlementExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct($config, $reserved)
$this->groupNameAARC ? Configuration::REQUIRED_OPTION : ''
);

$this->entityId = $configuration->getString(self::ENTITY_ID, null);
$this->entityId = $configuration->getValue(self::ENTITY_ID, null);

$interface = $configuration->getValueValidate(
self::INTERFACE_PROPNAME,
Expand All @@ -82,6 +82,13 @@ public function process(&$request)

if ($this->entityId === null) {
$this->entityId = EntitlementUtils::getSpEntityId($request);
} elseif (is_callable($this->entityId)) {
$this->entityId = call_user_func($this->entityId, $request);
} elseif (!is_string($this->entityId)) {
throw new Exception(
'perun:PerunEntitlement: invalid configuration option entityID. ' .
'It must be a string or a callable.'
);
}

if (isset($request['perun']['groups'])) {
Expand Down