diff options
| author | Tom Christie | 2011-04-27 18:20:29 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-04-27 18:20:29 +0100 |
| commit | da60f68f50dbcc177cb8b31df428d2daa905e9c6 (patch) | |
| tree | 6393597cdf4b6b0cc84f5ce792d3770d011aa189 /djangorestframework/authenticators.py | |
| parent | 659898ffaf24f74b62e73c487cd81bad21904790 (diff) | |
| parent | b508ca38d44f458e3eabaa4ffd3500d80a71eb9e (diff) | |
| download | django-rest-framework-da60f68f50dbcc177cb8b31df428d2daa905e9c6.tar.bz2 | |
Merge previous checkins
Diffstat (limited to 'djangorestframework/authenticators.py')
| -rw-r--r-- | djangorestframework/authenticators.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/djangorestframework/authenticators.py b/djangorestframework/authenticators.py index 19181b7d..29fbb818 100644 --- a/djangorestframework/authenticators.py +++ b/djangorestframework/authenticators.py @@ -64,14 +64,16 @@ class UserLoggedInAuthenticator(BaseAuthenticator): """Use Django's built-in request session for authentication.""" def authenticate(self, request): if getattr(request, 'user', None) and request.user.is_active: - # Temporarily set request.POST to view.RAW_CONTENT, - # so that we use our more generic request parsing, - # in preference to Django's form-only request parsing. - request._post = self.view.RAW_CONTENT - resp = CsrfViewMiddleware().process_view(request, None, (), {}) - del(request._post) - if resp is None: # csrf passed - return request.user + # If this is a POST request we enforce CSRF validation. + if request.method.upper() == 'POST': + # Temporarily replace request.POST with .RAW_CONTENT, + # so that we use our more generic request parsing + request._post = self.mixin.RAW_CONTENT + resp = CsrfViewMiddleware().process_view(request, None, (), {}) + del(request._post) + if resp is not None: # csrf failed + return None + return request.user return None |
