diff options
| author | Tom Christie | 2013-02-28 17:58:58 +0000 |
|---|---|---|
| committer | Tom Christie | 2013-02-28 17:58:58 +0000 |
| commit | 13b3af0d22bdbae5be0eb39ea50219c1fb83e28f (patch) | |
| tree | 26faec0481b8bb82e726ac4fc109b5f65d292a82 /rest_framework/views.py | |
| parent | 4e14b26fa9727a79f8ae7c7ef25d1339500fa26c (diff) | |
| download | django-rest-framework-13b3af0d22bdbae5be0eb39ea50219c1fb83e28f.tar.bz2 | |
Auth is no longer lazy. Closes #667.
More consistent auth failure behavior.
Diffstat (limited to 'rest_framework/views.py')
| -rw-r--r-- | rest_framework/views.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rest_framework/views.py b/rest_framework/views.py index fa742582..81cbdcbb 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -257,6 +257,16 @@ class APIView(View): return (renderers[0], renderers[0].media_type) raise + def perform_authentication(self, request): + """ + Perform authentication on the incoming request. + + Note that if you override this and simply 'pass', then authentication + will instead be performed lazily, the first time either + `request.user` or `request.auth` is accessed. + """ + request.user + def check_permissions(self, request): """ Check if the request should be permitted. @@ -305,6 +315,7 @@ class APIView(View): self.format_kwarg = self.get_format_suffix(**kwargs) # Ensure that the incoming request is permitted + self.perform_authentication(request) self.check_permissions(request) self.check_throttles(request) |
