Skip to content

Commit

Permalink
Don’t let sitepaths reveal that access-controlled items exist, to una…
Browse files Browse the repository at this point in the history
…uthorized users.
  • Loading branch information
grantneufeld committed Jun 11, 2011
1 parent 298a01f commit 1168123
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/paths_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def sitepath
requires_view_authority
render_path_item(@path.item)
end
rescue Wayground::AccessDenied
# don’t reveal to unauthorized users that an item exists if it is access controlled
missing
end

# GET /paths
Expand Down
13 changes: 13 additions & 0 deletions spec/controllers/paths_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ def mock_path(stubs={})
get :sitepath, {:url => path.sitepath}
response.status.should eq 501
end
it "shows the 404 missing error if the Path’s item requires authority to view" do
page = Factory.create(:page, {:is_authority_controlled => true})
path = Factory.create(:path, {:item => page})
get :sitepath, {:url => path.sitepath}
response.status.should eq 404
end
it "allows an authorized user to access an authority controlled item" do
set_logged_in_admin
page = Factory.create(:page, {:is_authority_controlled => true})
path = Factory.create(:path, {:item => page})
get :sitepath, {:url => path.sitepath}
response.status.should eq 200
end
end

describe "GET index" do
Expand Down

0 comments on commit 1168123

Please sign in to comment.