Skip to content

Commit 4c018ad

Browse files
committed
handle /dataset and /dataset/
without it, /dataset returns 500 instead of 403.
1 parent 3ab08dc commit 4c018ad

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ckanext/datagov_inventory/plugin.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,15 @@ def get_blueprint(self):
118118
def redirect_homepage():
119119
if current_user.is_authenticated or g.user:
120120
CKAN_SITE_URL = config.get("ckan.site_url")
121-
return redirect(CKAN_SITE_URL + '/dataset', code=302)
121+
return redirect(CKAN_SITE_URL + '/dataset/', code=302)
122122
else:
123123
return base.render(u'error/anonymous.html')
124124

125125

126126
pusher.add_url_rule('/', view_func=redirect_homepage)
127+
128+
@pusher.before_app_request
129+
def check_dataset_access():
130+
if toolkit.request.path in ('/dataset/', '/dataset'):
131+
if not current_user.is_authenticated and not g.user:
132+
return base.render(u'error/anonymous.html'), 403

e2e/cypress/integration/public_access.cy.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ describe('Public Access', () => {
2626
}).then((response) => {
2727
expect(response.status).to.eq(403);
2828
});
29+
30+
cy.request({
31+
url: '/dataset/',
32+
failOnStatusCode: false,
33+
}).then((response) => {
34+
expect(response.status).to.eq(403);
35+
});
2936
});
3037

3138
it('Cannot access the dataset pages', () => {

0 commit comments

Comments
 (0)