@@ -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