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

Register protected utility (Register protected vocabulary) #65

Open
ksuess opened this issue Dec 1, 2021 · 2 comments
Open

Register protected utility (Register protected vocabulary) #65

ksuess opened this issue Dec 1, 2021 · 2 comments

Comments

@ksuess
Copy link

ksuess commented Dec 1, 2021

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

Maybe I am wrong, but queryUtility seems to return a utility without a permission check.
Background is the need to protect vocabularies:

  <utility
      provides="zope.schema.interfaces.IVocabularyFactory"
      name="plone.restapi.testing.protected_vocabulary"
      component=".tests.test_services_vocabularies.test_vocabulary_factory"
      permission="cmf.ManagePortal"
      />

What I did:

zope.component is kind of complex. I got so far that I think there is a permission checker missing in zope.component.zcml.utility

        if component:
            # checker = Checker({
            #     '__call__': permission
            # })
            checker = _checker(component, permission, None, None)
            component = proxify(
                component,
                checker,
                provides,
                permission
            )

if permission is not None:
if component:
component = proxify(component, provides=provides,
permission=permission)

Even with the checker its not obvious for me why the permission is not regarded.

What I expect to happen:

queryUtility does check the permission of the utility registration.

What actually happened:

permission is ignored.

What version of Python and Zope/Addons I am using:

  • Python 3
  • Plone 6

Before we implement a security check in plone.app.vocabulary and maybe also in plone.restapi, I would like to know more about queryUtility and protected utilities. As any implementation (for example plone/plone.restapi#1287) in Plone does keep the door open for quering a utility without permission check.

@d-maurer
Copy link

d-maurer commented Dec 1, 2021 via email

@ksuess
Copy link
Author

ksuess commented Dec 1, 2021

Thanks for the explanation! I'm on the way getting a better understanding.

Just as a comment to our use case "protected vocabulary" in Plone:
Maybe an abstraction layer like https://github.com/zopefoundation/zope.vocabularyregistry would come in handy to

  • query vocabularies
  • check permissions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants