Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some auth functions not using IAuthFunctions
Various auth functions are purely wrappers around other auth functions. Unfortunately this means when overriding one of auth functions (a parent) that is used by others (children), the children will still call the original version, not the overridden version. This commit fixes this for most cases.
- Loading branch information
Showing
9 changed files
with
160 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
from ckan import logic | ||
import ckan.logic.auth.update as _update | ||
import ckan.authz as authz | ||
|
||
package_patch = _update.package_update | ||
|
||
resource_patch = _update.resource_update | ||
def package_patch(context, data_dict): | ||
return authz.is_authorized('package_update', context, data_dict) | ||
|
||
group_patch = _update.group_update | ||
|
||
organization_patch = _update.organization_update | ||
def resource_patch(context, data_dict): | ||
return authz.is_authorized('resource_update', context, data_dict) | ||
|
||
|
||
def group_patch(context, data_dict): | ||
return authz.is_authorized('group_update', context, data_dict) | ||
|
||
|
||
def organization_patch(context, data_dict): | ||
return authz.is_authorized('organization_update', context, data_dict) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
ckanext/example_iauthfunctions/plugin_v6_parent_auth_functions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pylons.config as config | ||
|
||
import ckan.plugins as plugins | ||
import ckan.plugins.toolkit as toolkit | ||
|
||
|
||
def package_delete(context, data_dict=None): | ||
return {'success': False, | ||
'msg': 'Only sysadmins can delete packages'} | ||
|
||
|
||
class ExampleIAuthFunctionsPlugin(plugins.SingletonPlugin): | ||
plugins.implements(plugins.IAuthFunctions) | ||
|
||
def get_auth_functions(self): | ||
return {'package_delete': package_delete} |
Oops, something went wrong.