diff options
| author | Tom Christie | 2012-10-28 12:10:12 -0700 |
|---|---|---|
| committer | Tom Christie | 2012-10-28 12:10:12 -0700 |
| commit | 1b2c2358476fd7948f87c5c161344a44de28275f (patch) | |
| tree | a3088824474b6be5a6195290c524bb4359b5b64d /rest_framework | |
| parent | 1eb56ebdd922907fd6c0598f1cae659b8f8a4e42 (diff) | |
| parent | af96fe05d0138c34128fc3944fc2701cbad5bd01 (diff) | |
| download | django-rest-framework-1b2c2358476fd7948f87c5c161344a44de28275f.tar.bz2 | |
Merge pull request #327 from tomchristie/allow-any-permission
Add AllowAny permission
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/permissions.py | 11 | ||||
| -rw-r--r-- | rest_framework/settings.py | 9 |
2 files changed, 17 insertions, 3 deletions
diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index 51e96196..655b78a3 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -18,6 +18,17 @@ class BasePermission(object): raise NotImplementedError(".has_permission() must be overridden.") +class AllowAny(BasePermission): + """ + Allow any access. + This isn't strictly required, since you could use an empty + permission_classes list, but it's useful because it makes the intention + more explicit. + """ + def has_permission(self, request, view, obj=None): + return True + + class IsAuthenticated(BasePermission): """ Allows access only to authenticated users. diff --git a/rest_framework/settings.py b/rest_framework/settings.py index 3c508294..9c40a214 100644 --- a/rest_framework/settings.py +++ b/rest_framework/settings.py @@ -37,11 +37,14 @@ DEFAULTS = { 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.BasicAuthentication' ), - 'DEFAULT_PERMISSION_CLASSES': (), - 'DEFAULT_THROTTLE_CLASSES': (), + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.AllowAny', + ), + 'DEFAULT_THROTTLE_CLASSES': ( + ), + 'DEFAULT_CONTENT_NEGOTIATION_CLASS': 'rest_framework.negotiation.DefaultContentNegotiation', - 'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.serializers.ModelSerializer', 'DEFAULT_PAGINATION_SERIALIZER_CLASS': |
