Is possible to add a decorator/wrapper in urls.py to protect not just one view but the root namespace of multiple views
urlpatterns = [
.....
path("", include("demandes.page_urls"), auth_fn), # where auth_fn is some impl of UserPassesTestMixin or similar
path("", include("organisation.page_urls")),
...
]
I ended up writing a RouteAuthMiddleware that check if the user is authenticated (and not a superuser) and then runs group and perm_checks based on the URL.
Definitely should not be abused but it works for me as these are completely different dashboards that target completely different classes of users with permissions that can granularly provisioned
That being said, route-level middleware would be a cool feature to tack on