From f880c976955bd1e066eb6c8815d1eec89d1f4308 Mon Sep 17 00:00:00 2001 From: Dragan Avramovic Date: Fri, 27 Nov 2020 10:04:15 +0100 Subject: [PATCH] RSS feeds access (#5) * [exception][xs] Make exception for RSS feeds * [fix][xs] Fix typo error and remove .atom * [fix][xs] Fix typo error * Added startswith('/feeds/') --- ckanext/noanonaccess/plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ckanext/noanonaccess/plugin.py b/ckanext/noanonaccess/plugin.py index ce1f377..5d67d7d 100644 --- a/ckanext/noanonaccess/plugin.py +++ b/ckanext/noanonaccess/plugin.py @@ -23,6 +23,8 @@ def __call__(self, environ, start_response): if catalog_endpoint: catalog_endpoint = catalog_endpoint.split('/{_format}') catalog_endpoints.append(catalog_endpoint[0]) + # Get feeds_access variable from the config object + feeds_access = config.get('ckanext.noanonaccess.allow_feeds') # we putting only UI behind login so API paths should remain accessible # also, allow access to dataset download and uploaded files if '/api/' in environ['PATH_INFO'] or '/datastore/dump/' in environ['PATH_INFO']: @@ -39,6 +41,10 @@ def __call__(self, environ, start_response): # If dcat_acess is enabled in the .env file make dataset and # catalog pages accessible return self.app(environ,start_response) + elif feeds_access and environ['PATH_INFO'].startswith('/feeds/'): + # If feeds_acess is enabled in the .env file + # make RSS feeds page accessible + return self.app(environ,start_response) else: # otherwise only login/reset are accessible if (environ['PATH_INFO'] == '/user/login' or environ['PATH_INFO'] == '/user/_logout'