flask-rbac icon indicating copy to clipboard operation
flask-rbac copied to clipboard

Unable to use Flask-FontAwesome: the css and js are 403 blocked

Open elanor-sparx opened this issue 2 years ago • 0 comments

Note, I have app.config['RBAC_USE_WHITE'] = True in my app.

This issue probably applies to other packages that initialise the css/js from the app and include it in the html headers like

<head>
    ...
    {{ fontawesome_html() }}
    ...
</head>

The solution in my case is to exempt the endpoint "fontawesome.static". Decided to work-around thusly in order to populate the _exempt list for each instance:

MRBAC.py

from flask_rbac import RBAC


class MRBAC(RBAC):

    ADDITIONAL_EXEMPTIONS = [
        "fontawesome.static"
    ]

    def __init__(self):
        super().__init__()
        self.do_additional_exemptions()

    def do_additional_exemptions(self):
        for e in self.ADDITIONAL_EXEMPTIONS:
            self.acl.exempt(e)


rbac = MRBAC()

and in the application's init.py:

from app.MRBAC import MRBAC
rbac = MRBAC()

elanor-sparx avatar Apr 28 '22 09:04 elanor-sparx