esmero / format_strawberryfield

Set of Display formatters, extractors and utils to make Strawberry field data glow
GNU Lesser General Public License v3.0
6 stars 9 forks source link

Allow IP based embargo to act on an array of multiple address/ranges. #377

Closed DiegoPino closed 10 months ago

DiegoPino commented 10 months ago

What?

This is on me. I coded/hardcoded the IP address validation to be done against a single valued JSON Key instead of an array of possible IPs/Ranges that allow an embargo to be bypassed.

The offending (more like single acting) code is this

if (strlen($ip_embargo_key) > 0 && !empty($jsondata[$ip_embargo_key]) && is_string($jsondata[$ip_embargo_key])) {
        $current_ip =  $this->requestStack->getCurrentRequest()->getClientIp();
        if ($current_ip) {
          $ip_embargo = IpUtils::checkIp4($current_ip, trim($jsondata[$ip_embargo_key]));
          $noembargo = $noembargo && $ip_embargo;
        }
      }

And what I need to add is a different strategy (iterating over each entry and accumulating/binary OR/AND resolved embargo bypasses if the field contains multiple single strings.

@alliomeria what I mentioned today.

DiegoPino commented 10 months ago

Resolved via #383 and #382