Set the list of allowed domains.

Accepts a string or an array of domains that have CORS enabled.
You can use `*.example.com` wildcards to accept subdomains, or `*` to allow all domains

@param string|array $domain The allowed domains
@return $this
349193
public function allowOrigin($domain)
    {
        $allowed = $this->_normalizeDomains((array)$domain);
        foreach ($allowed as $domain) {
            if (!preg_match($domain['preg'], $this->_origin)) {
                continue;
            }
            $value = $domain['original'] === '*' ? '*' : $this->_origin;
            $this->_headers['Access-Control-Allow-Origin'] = $value;
            break;
        }

        return $this;
    }
806710
protected function isValidDomain($domain)
    {
        if (filter_var($domain, FILTER_VALIDATE_URL) === false) {
            $this->eye->logger()->debug('SSL URL not valid', $domain);
            return false;
        }

        return true;
    }
897387
public function setOptions(array $options = array())
    {
        if (array_key_exists('messages', $options)) {
            $this->setMessages($options['messages']);
        }

        if (array_key_exists('hostname', $options)) {
            if (array_key_exists('allow', $options)) {
                $this->setHostnameValidator($options['hostname'], $options['allow']);
            } else {
                $this->setHostnameValidator($options['hostname']);
            }
        } elseif ($this->_options['hostname'] == null) {
            $this->setHostnameValidator();
        }

        if (array_key_exists('mx', $options)) {
            $this->setValidateMx($options['mx']);
        }

        if (array_key_exists('deep', $options)) {
            $this->setDeepMxCheck($options['deep']);
        }

        if (array_key_exists('domain', $options)) {
            $this->setDomainCheck($options['domain']);
        }

        return $this;
    }
1333211
protected function validateDomainName($domain)
    {
        if (!array_key_exists($domain, $this->domains)) {
            throw new InvalidArgumentException(sprintf(
                'Domain "%s" is not valid. Valid domains are: %s',
                $domain,
                implode(', ', array_keys($this->domains))
            ));
        }
    }
339678
protected function _validateDomain($domain)
    {
        // Note the different use of $subdomains and $sub_domains
        $subdomains = explode('.', $domain);

        while (count($subdomains) > 0) {
            $sub_domains[] = $this->_splitCheck($subdomains, '.');
            for ($i = 0; $i < $this->index + 1; $i++)
                array_shift($subdomains);
        }

        foreach ($sub_domains as $sub_domain) {
            if (!$this->_validateSubdomain(trim($sub_domain)))
                return false;
        }

        // Managed to get here, so return input.
        return $domain;
    }
1132778
public function restrictSubdomain($subdomain) {
        if ( ! is_array($subdomain)) {
            $subdomain = [$subdomain];
        }

        $this->getRoutesMatcher()->getRestrictionsMatcher()
            ->setSubdomains($subdomain);

        return $this;
    }
249834
function setDomain()
    {
        $this->domains = func_get_args();
        $this->removeDNProp('id-at-commonName');
        $this->setDNProp('id-at-commonName', $this->domains[0]);
    }
1173210
public function setDomain($domain)
    {
        try {
            $this->domain = (string) $domain;
        } catch (Exception $e) {
            throw new InvalidArgumentException(
                'Value provided as domain is not a string'
            );
        }

        return $this;
    }
1219235
public function setDomains($domains)
    {
        if (is_array($domains)) {
            foreach ($domains as $domain) {
                $this->setDomains($domain);
            }
            return $this;
        }

        $this->domains[] = $domains;

        return $this;
    }
296448
public function setPermissions($value)
    {
        $allowedResources = self::allowedResources();
        $allowedMethods = self::allowedMethods();

        if ($value !== null && !is_array($value)) {
            throw new DomainException(self::MSG_INVALID_FORMAT);
        }

        foreach ($value as $rule) {
            if (!is_array($rule)) {
                throw new DomainException(self::MSG_INVALID_FORMAT);
            }

            if (!empty($rule['resourceName']) && !in_array($rule['resourceName'], $allowedResources, true)) {
                throw new DomainException(sprintf(self::MSG_UNEXPECTED_RESOURCE, implode(', ', $allowedResources)));
            }

            if (!empty($rule['resourceIds']) && !is_array($rule['resourceIds'])) {
                throw new DomainException(self::MSG_INVALID_RESOURCE_IDS);
            }

            if (!empty($rule['methods']) && !is_array($rule['methods'])) {
                throw new DomainException(self::MSG_INVALID_METHODS);
            }

            if (!empty($rule['methods'])) {
                foreach ($rule['methods'] as $method) {
                    if (!in_array($method, $allowedMethods, true)) {
                        throw new DomainException(sprintf(self::MSG_UNEXPECTED_METHOD, implode(', ', $allowedMethods)));
                    }
                }
            }
        }

        return $this->setAttribute('permissions', $value);
    }
662648
public function removeDomain($domain)
    {
        if (isset($this->domains[$domain])) {
            unset($this->domains[$domain]);
        }

        return $this;
    }
1048048
public function domain($domain)
    {
        if (empty($domain) || trim($domain) !== $domain) {
            throw new Exception('Invalid domain "' . $domain . '"', 2);
        } else {
            $this->domain = $domain;
        }

        return $this;
    }
854210
public function setDomain(Domain $domain)
    {
        $this->domain = $domain;
        $this->domainId = $domain->getDomainId();
    }
797919
public function setConfig(array $config)
    {
        // Filter out unknown config keys, and use to override defaults
        $config = array_merge(
            $this->config,
            array_intersect_key($config, $this->config)
        );

        // Normalize allowMethods
        if (is_string($config['allowMethods'])) {
            $config['allowMethods'] = [$config['allowMethods']];
        }

        // Normalize allowHeaders
        if (is_string($config['allowHeaders'])) {
            $config['allowHeaders'] = [$config['allowHeaders']];
        }

        // Normalize allowOrigins
        if (is_string($config['allowOrigins'])) {
            $config['allowOrigins'] = [$config['allowOrigins']];
        }

        // Normalize allowCredentials
        $config['allowCredentials'] = (bool)$config['allowCredentials'];

        // Normalize maxAge
        $config['maxAge'] = (int)$config['maxAge'];

        /** @todo Check for use of wildcard in allowOrigins when allowCredentials equals true */

        // Set config as object attribute
        $this->config = $config;

        return $this;
    }
832850
private function isValidDomains(array $domains): void
    {
        $this->isValidArray($domains, 50);

        foreach ($domains as $domain) {
            $this->isValidUrl($domain);
        }
    }
41431
public function cookie($domain)
    {
        $this->bag->set(CURLOPT_COOKIEJAR, $this->getPath($domain, 'cookie'));
        $this->bag->set(CURLOPT_COOKIEFILE, $this->getPath($domain, 'cookie'));

        return $this;
    }
1280546
public function setFlags($flags)
    {
        if (!is_int($flags)) {
            throw new InvalidArgumentException('integer', 0);
        }

        if (($flags & FORCE_USE_PROC_OPEN) && ($flags & FORCE_USE_EXEC)) {
            throw new DomainException("Invalid flags: FORCE_USE_PROC_OPEN and FORCE_USE_EXEC cannot be set at the same time");
        }

        $this->flags = $flags;

        return $this;
    }