Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changes/219.canada.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Added a `ckan.site_read_only` config option which disables actions causing side effects,
such as `*_create`, `*_update`, and `*_delete`, for non-sysadmin users.

This setting does not prevent updates to the database from sysadmin users or updates
that skip the action API, such as collecting page view tracking data.
7 changes: 7 additions & 0 deletions ckan/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def is_authorized(action: str, context: Context,
if not getattr(auth_function, 'auth_sysadmins_check', False):
return {'success': True}

# (canada fork only): site read only mode
# TODO: upstream contrib!!!
if config.get('ckan.site_read_only', False):
if not getattr(p.toolkit.get_action(action), 'side_effect_free', False):
return {'success': False,
'msg': _('Site is in read only mode')}

# If the auth function is flagged as not allowing anonymous access,
# and an existing user object is not provided in the context, deny
# access straight away
Expand Down