Skip to content

Commit 31505f0

Browse files
authored
Merge pull request #382 from esmero/ISSUE-377
ISSUE-377: Allow multiple IP addresses/ranges to dictate which IPs can bypass an…
2 parents a244770 + 1d6cb6f commit 31505f0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/EmbargoResolver.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,23 @@ public function embargoInfo(string $uuid, array $jsondata) {
123123
}
124124
}
125125
$ip_embargo_key = $this->embargoConfig->get('ip_json_key');
126-
if (strlen($ip_embargo_key) > 0 && !empty($jsondata[$ip_embargo_key]) && is_string($jsondata[$ip_embargo_key])) {
126+
if (strlen($ip_embargo_key) > 0 && !empty($jsondata[$ip_embargo_key])) {
127127
$current_ip = $this->requestStack->getCurrentRequest()->getClientIp();
128128
if ($current_ip) {
129-
$ip_embargo = IpUtils::checkIp4($current_ip, trim($jsondata[$ip_embargo_key]));
130-
$noembargo = $noembargo && $ip_embargo;
129+
if (is_array($jsondata[$ip_embargo_key])) {
130+
foreach($jsondata[$ip_embargo_key] as $ip_embargo_value) {
131+
if (is_string($ip_embargo_value)) {
132+
$ip_embargo = IpUtils::checkIp4($current_ip, trim($ip_embargo_value)) || $ip_embargo;
133+
// Here we need to do it differently. We will || all the $ip_embargo
134+
// and then check the $noembargo variable outside of this loop
135+
}
136+
}
137+
$noembargo = $noembargo && $ip_embargo;
138+
}
139+
elseif (is_string($jsondata[$ip_embargo_key])) {
140+
$ip_embargo = IpUtils::checkIp4($current_ip, trim($jsondata[$ip_embargo_key]));
141+
$noembargo = $noembargo && $ip_embargo;
142+
}
131143
}
132144
}
133145
$embargo_info = [!$noembargo, $date_embargo ? $date: FALSE , $ip_embargo];

0 commit comments

Comments
 (0)