class RemoteFileDestinationPolicy extends PublicDestinationPolicy

Constants

protected DISALLOWED_NETWORKS

Methods

__construct(Closure|null $resolver = null)

Create a destination policy for a remote file download.

resolve(string $url, float $timeoutSeconds)

Resolve and authorize one outbound destination within the given time budget.

void
validate(string $url)

Validate a destination URL without resolving it, such as before storing one a user entered.

string|null
proxyFor(UriInterface $uri)

Return an approved proxy for the destination.

bool
allowsAddress(UriInterface $uri, string $address)

Determine whether a non-public address may be used.

array
resolveHost(string $host, float $timeoutSeconds)

Resolve a hostname using the configured resolver or the system resolver.

array|false
resolveAddressFamily(string $host, int $family, float $timeoutSeconds)

Resolve one address family within its share of the request budget.

Details

at line 17
__construct(Closure|null $resolver = null)

Create a destination policy for a remote file download.

Parameters

Closure|null $resolver

ResolvedDestination resolve(string $url, float $timeoutSeconds)

Resolve and authorize one outbound destination within the given time budget.

Parameters

string $url
float $timeoutSeconds

Return Value

ResolvedDestination

Exceptions

DisallowedDestinationException
DestinationResolutionException
ProxyConnectionException

void validate(string $url)

Validate a destination URL without resolving it, such as before storing one a user entered.

A host given as an address literal is authorized now. A hostname is not resolved, so its addresses are checked when a request resolves them.

Parameters

string $url

Return Value

void

Exceptions

DisallowedDestinationException

protected string|null proxyFor(UriInterface $uri)

Return an approved proxy for the destination.

Applications that require trusted egress proxies may extend this policy and select an absolute URL from a bounded operator-configured set. The policy then vets and pins only the proxy: hostname targets are resolved by the proxy, so it must enforce the same destination rules itself.

Parameters

UriInterface $uri

Return Value

string|null

protected bool allowsAddress(UriInterface $uri, string $address)

Determine whether a non-public address may be used.

Applications may narrowly allow known internal destinations by extending this policy. Every resolved address must be allowed.

Parameters

UriInterface $uri
string $address

Return Value

bool

at line 28
protected array resolveHost(string $host, float $timeoutSeconds)

Resolve a hostname using the configured resolver or the system resolver.

Parameters

string $host
float $timeoutSeconds

Return Value

array

protected array|false resolveAddressFamily(string $host, int $family, float $timeoutSeconds)

Resolve one address family within its share of the request budget.

Parameters

string $host
int $family
float $timeoutSeconds

Return Value

array|false