Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions changes/219.canada.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a `ckan.site_read_only` config option which disables `_create`, `_update`, `_patch`, and `_delete` actions for non-sysadmin users.
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