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

Commit 7cbb212

Browse files
committed
Fixed authorisation
If the user is not member of any assigned group to the SP, then raise unauthorized page
1 parent 78fd095 commit 7cbb212

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

lib/Auth/Process/PerunIdentity.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ public function process(&$request)
145145
$groups = $this->intersectById($spGroups, $memberGroups);
146146

147147
if (empty($groups)) {
148-
SimpleSAML_Logger::info('Perun user with identity: '.$uid.' has been found but SP does NOT have sufficient rights to get information about him. '.
149-
'User has to register to specific VO or Group. He is being redirected to register. ');
150-
$this->register($request, $this->registerUrl, $this->callbackParamName, $vo, $spGroups, $this->interface);
148+
SimpleSAML_Logger::info('Perun user with identity: '.$uid.' is not member of any assigned group for resource (' . $spEntityId . ')');
149+
$this->unauthorized($request);
151150
}
152151

153152
SimpleSAML_Logger::info('Perun user with identity: '.$uid.' has been found and SP has sufficient rights to get info about him. '.
@@ -297,5 +296,24 @@ private function containsMembersGroup($entities)
297296
return false;
298297
}
299298

300-
299+
/**
300+
* When the process logic determines that the user is not
301+
* authorized for this service, then forward the user to
302+
* an 403 unauthorized page.
303+
*
304+
* Separated this code into its own method so that child
305+
* classes can override it and change the action. Forward
306+
* thinking in case a "chained" ACL is needed, more complex
307+
* permission logic.
308+
*
309+
* @param array $request
310+
*/
311+
protected function unauthorized(&$request) {
312+
// Save state and redirect to 403 page
313+
$id = SimpleSAML_Auth_State::saveState($request,
314+
'authorize:Authorize');
315+
$url = SimpleSAML_Module::getModuleURL(
316+
'authorize/authorize_403.php');
317+
\SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id));
318+
}
301319
}

0 commit comments

Comments
 (0)