diff options
| author | Pierre Dulac | 2013-03-01 11:50:11 +0100 |
|---|---|---|
| committer | Pierre Dulac | 2013-03-01 11:50:11 +0100 |
| commit | aed3c13471deae6b2837b3799b4ca6615a5d172c (patch) | |
| tree | 13f3f0a7cb36923dd9dcd84374af1a93f6b30a24 /rest_framework/views.py | |
| parent | d8f455bc0ff920e9e0cd1952f58b5a0eccdc2683 (diff) | |
| parent | 282af6057f30b5af4665d687200ee1ebf82fcf00 (diff) | |
| download | django-rest-framework-aed3c13471deae6b2837b3799b4ca6615a5d172c.tar.bz2 | |
Merge branch 'master' into oauth2-authentication
Conflicts:
rest_framework/tests/authentication.py
Diffstat (limited to 'rest_framework/views.py')
| -rw-r--r-- | rest_framework/views.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/rest_framework/views.py b/rest_framework/views.py index 69377bc0..81cbdcbb 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -8,7 +8,7 @@ from django.utils.html import escape from django.utils.safestring import mark_safe from django.views.decorators.csrf import csrf_exempt from rest_framework import status, exceptions -from rest_framework.compat import View, apply_markdown, smart_text +from rest_framework.compat import View, apply_markdown from rest_framework.response import Response from rest_framework.request import Request from rest_framework.settings import api_settings @@ -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) |
