From 8ede2402bd2391d2e8e25c49c8946d8afb0e2fd9 Mon Sep 17 00:00:00 2001 From: Ollie Treend Date: Fri, 22 Sep 2023 12:58:34 +0100 Subject: [PATCH 1/2] Update external redirect validation error message The validation error message was hardcoded and no longer reflected the full list of allowed domains. This confused me when trying to debug a failing external redirect because I expected the error message to list all the allowed domains. I've made this error message dynamic so it always reflects the current allow list. Before: external redirects only accepted within the gov.uk, judiciary.uk, nhs.uk or ukri.org domains After: external redirects only accepted for the domains .gov.uk, .judiciary.uk, .nationalhighways.co.uk, .nhs.uk, .police.uk, and .ukri.org --- app/validators/routes_and_redirects_validator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/validators/routes_and_redirects_validator.rb b/app/validators/routes_and_redirects_validator.rb index c470fe615..c852158bf 100644 --- a/app/validators/routes_and_redirects_validator.rb +++ b/app/validators/routes_and_redirects_validator.rb @@ -198,7 +198,7 @@ def validate_external_redirect(destination) return end - errors.add(:redirects, "external redirects only accepted within the gov.uk, judiciary.uk, nhs.uk or ukri.org domains") unless + errors.add(:redirects, "external redirects only accepted for the domains #{EXTERNAL_HOST_ALLOW_LIST.to_sentence}") unless government_domain?(uri.host) errors.add(:redirects, "internal redirect should not be specified with full url") if From 38dc1c74c68c9cca386d301d909ababea4e79f09 Mon Sep 17 00:00:00 2001 From: Ollie Treend Date: Fri, 22 Sep 2023 13:06:11 +0100 Subject: [PATCH 2/2] Allow external redirects to caa.co.uk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows users to unpublish documents and redirect it to URLs on the Civil Aviation Authority (CAA) website. Requested in Zendesk ticket: https://govuk.zendesk.com/agent/tickets/4994883 And agreed in Slack thread: https://gds.slack.com/archives/CACV3TACU/p1694690016148749 I originally added this to Whitehall in PR alphagov/whitehall#8290 before realising that the document to be unpublished & redirected is actually published via Specialist Publisher, and therefore this is actually where the list needs updating. 🙈 --- app/validators/routes_and_redirects_validator.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/validators/routes_and_redirects_validator.rb b/app/validators/routes_and_redirects_validator.rb index c852158bf..dd65cfe2d 100644 --- a/app/validators/routes_and_redirects_validator.rb +++ b/app/validators/routes_and_redirects_validator.rb @@ -1,5 +1,6 @@ class RoutesAndRedirectsValidator < ActiveModel::Validator EXTERNAL_HOST_ALLOW_LIST = %w[ + .caa.co.uk .gov.uk .judiciary.uk .nationalhighways.co.uk