Skip to content

Commit f9eb01c

Browse files
committed
Gate /component-guide behind GOV.UK Signon
Wraps the engine mount in a GDS::SSO::AuthorisedUserConstraint so the component-guide requires a signed-in Whitehall user. This keeps the guide available in all environments (per commit 8b3a40a) while ensuring it is not publicly accessible.
1 parent c2336b8 commit f9eb01c

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

config/routes.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,7 @@ def redirect(path, options = { prefix: Whitehall.router_prefix })
453453

454454
mount Flipflop::Engine => "/flipflop"
455455

456-
mount GovukPublishingComponents::Engine, at: "/component-guide"
456+
constraints(GDS::SSO::AuthorisedUserConstraint.new(User::Permissions::SIGNIN)) do
457+
mount GovukPublishingComponents::Engine, at: "/component-guide"
458+
end
457459
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require "test_helper"
2+
3+
class ComponentGuideTest < ActionDispatch::IntegrationTest
4+
test "redirects unauthenticated users to signon" do
5+
ENV["GDS_SSO_MOCK_INVALID"] = "1"
6+
get "/component-guide"
7+
assert_redirected_to "/auth/gds"
8+
end
9+
10+
test "allows access when signed in" do
11+
login_as_admin
12+
get "/component-guide"
13+
assert_response :success
14+
end
15+
end

0 commit comments

Comments
 (0)