abstract class SecuredRedirectResponse extends RedirectResponse (View source)

Provides a common base class for safe redirects.

In case you want to redirect to external URLs use TrustedRedirectResponse.

For local URLs we use LocalRedirectResponse which opts out of external redirects.

Methods

createFromRedirectResponse(RedirectResponse $response)

Copies an existing redirect response into a safe one.

fromResponse(RedirectResponse $response)

Copies over the values from the given response.

setTargetUrl($url)

{@inheritdoc}

bool
isSafe(string $url)

Returns whether the URL is considered as safe to redirect to.

Details

static SecuredRedirectResponse createFromRedirectResponse(RedirectResponse $response)

Copies an existing redirect response into a safe one.

The safe one cannot accidentally redirect to an external URL, unless actively wanted (see TrustedRedirectResponse).

Parameters

RedirectResponse $response

The original redirect.

Return Value

SecuredRedirectResponse

protected fromResponse(RedirectResponse $response)

Copies over the values from the given response.

Parameters

RedirectResponse $response

The redirect response object.

setTargetUrl($url)

{@inheritdoc}

Parameters

$url

abstract protected bool isSafe(string $url)

Returns whether the URL is considered as safe to redirect to.

Parameters

string $url

The URL checked for safety.

Return Value

bool