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

Unable to use @rbac.exempt with Blueprints #32

Open
daobeng opened this issue Jun 8, 2021 · 1 comment
Open

Unable to use @rbac.exempt with Blueprints #32

daobeng opened this issue Jun 8, 2021 · 1 comment

Comments

@daobeng
Copy link

daobeng commented Jun 8, 2021

PR-29 Added the ability to specify endpoints for the @rbac.allow and @rbac.deny to allow them to play nicely with blueprints

@rbac.exempt still uses the view_func.__name__ and hence, doesn't work with blueprints. For backwards compatibility, I suppose it might be useful to provide another exempt function that can take an endpoint parameter

If this is affecting any, the work around to inhert the RBAC and redefine the exempt decorator

class MRBAC(RBAC):
    def exempt(self, endpoint=None):
        def decorator(view_func):
            self.acl.exempt(endpoint or view_func.__name__)
            return view_func

        return decorator

rbac = MRBAC()

@blueprint.route('/everyone/can/access')
@rbac.exempt(endpoint='blueprint.everyone_can_access')
def everyone_can_access():
    return 'Hello~'
@elanor-sparx
Copy link

Same issue here, thanks for reporting daobeng & for workaround

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

No branches or pull requests

2 participants