Skip to content

TRUSTED_RETURN_HOSTS ​

After a successful login, the redirect module sends the user to the target held in user.redirect (eg. a SAML RelayState) or in the <TITLE>_redirect cookie. The cookie is set by the login view from a return_to query parameter, or by the request authentication middleware from the originally requested path.

  • A relative path which starts with a single / is always accepted.
  • An absolute URL is accepted only when its origin is listed in TRUSTED_RETURN_HOSTS. Any other target, and any target which fails to decode, falls back to DIR/.
  • If TRUSTED_RETURN_HOSTS is unset, every absolute target is rejected.
dotenv
TRUSTED_RETURN_HOSTS=https://admin.example.com,https://other.example.com

The value is split on commas and compared with the URL origin of the target: scheme, host and a non-default port, with no path or trailing slash. Entries are not trimmed, so do not put spaces after the commas.

Only list origins under your control. An entry allows a login to hand the signed-in user to that origin, so a broad allowlist turns the login route into an open redirect. Check the redirect implementation and its tests before changing this behaviour.

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.