URL Patterns to have login_required or equiv to force authentication on any of the url's in that pattern
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I found that protecting views from unauthorized access can become cumbersom when your building lots of protected pages.
Decorating a view with login_required to force authentication works perfectly, but is not DRY when decorating every view in an app.
In combination with generic views, there are a few problems here and there with generics that are not accepting login_required. (see ticket #1071)
If the url patterns had a way to set login_required on the entire list of expressions, one could protect an entire part of the site
with one simple statement. Mixing protected/unprotected patterns would still allow flexibility designing urlpatterns.
from django.conf.urls.defaults import * urlpatterns = patterns('myproject.myapp.views', (r'^$', 'index'), ) urlpatterns += auth_patterns('', some_options?, (r'^list_protected/$', 'django.views.generic.list_detail.object_list', dict(mydict)), (r'^add_protected/$', 'django.views.generic.create_update.create_object', dict(mydict)), (r'^update_protected/$', 'django.views.generic.create_update.update_object', dict(mydict)), (r'^delete_protected/$', 'django.views.generic.create_update.delete_object', dict(mydict)), )
Change History (2)
comment:1 Changed 10 years ago by
|Summary:||URL Patterns set have login_required or equiv to force authentication on any of the url's in that pattern → URL Patterns to have login_required or equiv to force authentication on any of the url's in that pattern|