Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not prevent Org-level admins from using bulk edit UI to set datasets Public #3

Open
reedv opened this issue Apr 1, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@reedv
Copy link
Owner

reedv commented Apr 1, 2021

Even though the extension is currently set to only allow sysadmins to set packages' visibility to public, I find that you can still use the bulk edit tool when managing an Org as an Org admin user to set datasets to public. This should not happen.

Note that when an Org admin user attempts to set a dataset to public individually via the regular web UI for editing individual datasets, they do get denied as expected. (Thus I do not think I have set the existing code wrong in some way that actually implies that Org admins changing visibility to public is allowed).

@reedv reedv added the bug Something isn't working label Apr 1, 2021
@reedv
Copy link
Owner Author

reedv commented Apr 1, 2021

enhancement #2 would not make sense until this issue is fixed

@reedv
Copy link
Owner Author

reedv commented Apr 14, 2021

Based on the info provided here: https://gitter.im/ckan/chat?at=6075457bb6a4714a29bf9130

see

https://github.com/ckan/ckan/search?q=bulk_update_public
https://github.com/ckan/ckan/blob/cc000d3acf7401957d8321be53e8cabc2d9ebf3a/ckan/logic/auth/update.py#L286

def bulk_update_public(context, data_dict):
    org_id = data_dict.get('org_id')
    user = context['user']
    authorized = authz.has_user_permission_for_group_or_org(org_id, user, 'update')
    if not authorized:
        return {'success': False}
    return {'success': True}

Could change to

def bulk_update_public(context, data_dict):
    org_id = data_dict.get('org_id')
    user = context['user']
    authorized = authz.has_user_permission_for_group_or_org(org_id, user, 'update') and authz.is_sysadmin(user)
    if not authorized:
        return {'success': False}
    return {'success': True}

@reedv
Copy link
Owner Author

reedv commented Apr 14, 2021

And if we were to implement enhancement #2, we would just use the normal version of the bulk_update_public function

@reedv
Copy link
Owner Author

reedv commented Apr 14, 2021

See https://docs.ckan.org/en/2.9/extensions/plugin-interfaces.html#ckan.plugins.interfaces.IAuthFunctions for how to work this auth override into an extension. (You'll need to import ckan.authz as authz into the plugin file as well)

@reedv reedv changed the title Does not prevent Org admins from using bulk edit UI to set datasets Public Does not prevent Org-level admins from using bulk edit UI to set datasets Public Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant