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

Commit 48c6949

Browse files
committed
fix: Minor fixes in AuthProc filters
1 parent 520bbb7 commit 48c6949

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

lib/Auth/Process/ForceAup.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ private function fillAupsToBeApproved($requestedAups, $aups, $userApprovedAups)
265265
{
266266
$aupsToBeApproved = [];
267267
foreach ($requestedAups as $requestedAup) {
268+
if (!array_key_exists($requestedAup, $aups)) {
269+
Logger::debug('perun:ForceAup - Requested AUP \'' . $requestedAup . '\' is not in the list of VO AUPS, probably VO does not have AUP');
270+
continue;
271+
}
268272
$aupsInJson = $aups[$requestedAup];
269273
if (empty($aupsInJson)) {
270274
continue;

lib/Auth/Process/PerunIdentity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public function process(&$request)
241241

242242
$this->checkMemberStateDefaultVo($request, $user, $uids);
243243

244-
$groups = $this->adapter->getUsersGroupsOnFacility($this->spEntityId, $user->getId());
244+
$groups = $this->adapter->getUsersGroupsOnSp($this->spEntityId, $user->getId());
245245

246246
if ($this->checkGroupMembership && empty($groups)) {
247247
if ($this->allowRegistrationToGroups) {

lib/Auth/Process/PerunUser.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ private function register(array &$request, array $uids): void
137137
self::PARAM_STATE_ID => $stateId,
138138
]);
139139
Logger::debug(self::DEBUG_PREFIX . 'Produced callback URL \'' . $callback . '\'');
140-
$url = '';
141140
$params = [];
142141

143142
if (!empty($this->registerUrl) && !empty($this->callbackParameterName)) {

lib/Auth/Process/SpAuthorization.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ public function process(&$request)
147147
Logger::debug(
148148
self::DEBUG_PREFIX . 'No facility found for SP \'' . $spEntityId . '\', skip processing filter'
149149
);
150-
151150
return;
152151
}
153152
$facilityAttributes = $this->getSPAttributes($facility);
@@ -156,22 +155,20 @@ public function process(&$request)
156155
self::DEBUG_PREFIX . 'Could not fetch SP attributes, user will be redirected to unauthorized for security reasons'
157156
);
158157
$this->unauthorized($request);
159-
160158
return;
161159
}
162160

163161
$checkGroupMembership = $facilityAttributes[self::CHECK_GROUP_MEMBERSHIP];
164162
if (!$checkGroupMembership) {
165163
Logger::info(self::DEBUG_PREFIX . 'Group membership check not requested by the service.');
166-
167164
return;
168165
}
169166

170-
$userGroups = $this->adapter->getUsersGroupsOnFacility($spEntityId, $user->getId());
167+
$userGroups = $this->adapter->getUsersGroupsOnFacility($facility, $user->getId());
171168
if (!empty($userGroups)) {
172169
Logger::info(self::DEBUG_PREFIX . 'User satisfies the group membership check.');
173170
} else {
174-
$this->handleUnsatisfiedMembership($request, $user, $spEntityId, $facilityAttributes);
171+
$this->handleUnsatisfiedMembership($request, $user, $spEntityId, $facility, $facilityAttributes);
175172
}
176173
}
177174

@@ -188,6 +185,7 @@ public function handleUnsatisfiedMembership(
188185
array $request,
189186
User $user,
190187
string $spEntityId,
188+
Facility $facility,
191189
array $facilityAttributes
192190
) {
193191
$allowRegistration = $facilityAttributes[self::ALLOW_REGISTRATION] ?? false;
@@ -208,11 +206,10 @@ public function handleUnsatisfiedMembership(
208206
exit;
209207
}
210208
try {
211-
$registrationData = $this->getRegistrationData($user, $spEntityId, $facilityAttributes);
209+
$registrationData = $this->getRegistrationData($user, $facility, $spEntityId, $facilityAttributes);
212210
if (!empty($registrationData)) {
213211
$skipNotification = in_array($spEntityId, $this->skipNotificationSps, true);
214212
$this->register($request, $registrationData, $skipNotification);
215-
216213
return;
217214
}
218215
Logger::debug(
@@ -223,7 +220,7 @@ public function handleUnsatisfiedMembership(
223220
Logger::warning(
224221
self::DEBUG_PREFIX . 'Caught exception, user will be redirected to unauthorized for security reasons'
225222
);
226-
Logger::debug($ex);
223+
Logger::debug($ex->getMessage());
227224
}
228225
} else {
229226
Logger::debug(
@@ -354,7 +351,7 @@ protected function registerChooseVoAndGroup(array &$request, array $registration
354351
]);
355352
}
356353

357-
private function getRegistrationData($user, $spEntityId, array $facilityAttributes): array
354+
private function getRegistrationData($user, Facility $facility, string $spEntityId, array $facilityAttributes): array
358355
{
359356
if (null === $this->rpcAdapter) {
360357
throw new Exception(self::DEBUG_PREFIX . 'No RPC adapter available, cannot fetch registration data');
@@ -367,7 +364,7 @@ private function getRegistrationData($user, $spEntityId, array $facilityAttribut
367364
}
368365
$voShorNamesForRegistration = $this->getRegistrationVoShortNames($user, $voShortNames);
369366

370-
return $this->getRegistrationGroups($spEntityId, $voShorNamesForRegistration);
367+
return $this->getRegistrationGroups($facility, $voShorNamesForRegistration);
371368
}
372369

373370
private function getRegistrationVoShortNames(User $user, array $voShortNames): array

0 commit comments

Comments
 (0)