Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit c14952e

Browse files
authored
feat: allow callable for entityID in PerunEntitlement
1 parent d309cec commit c14952e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/Auth/Process/PerunEntitlement.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct($config, $reserved)
6464
$this->groupNameAARC ? Configuration::REQUIRED_OPTION : ''
6565
);
6666

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

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

8383
if ($this->entityId === null) {
8484
$this->entityId = EntitlementUtils::getSpEntityId($request);
85+
} elseif (is_callable($this->entityId)) {
86+
$this->entityId = call_user_func($this->entityId, $request);
87+
} elseif (!is_string($this->entityId)) {
88+
throw new Exception(
89+
'perun:PerunEntitlement: invalid configuration option entityID. ' .
90+
'It must be a string or a callable.'
91+
);
8592
}
8693

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

0 commit comments

Comments
 (0)