diff options
| author | Tom Christie | 2013-01-22 09:12:48 -0800 |
|---|---|---|
| committer | Tom Christie | 2013-01-22 09:12:48 -0800 |
| commit | dd10d538ffc8f76ccc670f65da2220b09c22688c (patch) | |
| tree | 1af09c7dbcc939c749d30adf25b14d232200f44f /rest_framework/exceptions.py | |
| parent | e29ba356f054222893655901923811bd9675d4cc (diff) | |
| parent | b7ab2aee46c718f683b19eefba1b48f233da40e4 (diff) | |
| download | django-rest-framework-dd10d538ffc8f76ccc670f65da2220b09c22688c.tar.bz2 | |
Merge pull request #416 from tomchristie/unauthenticated_response
Unauthenticated requests - 401 vs 403 responses
Diffstat (limited to 'rest_framework/exceptions.py')
| -rw-r--r-- | rest_framework/exceptions.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 89479deb..d635351c 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -23,6 +23,22 @@ class ParseError(APIException): self.detail = detail or self.default_detail +class AuthenticationFailed(APIException): + status_code = status.HTTP_401_UNAUTHORIZED + default_detail = 'Incorrect authentication credentials.' + + def __init__(self, detail=None): + self.detail = detail or self.default_detail + + +class NotAuthenticated(APIException): + status_code = status.HTTP_401_UNAUTHORIZED + default_detail = 'Authentication credentials were not provided.' + + def __init__(self, detail=None): + self.detail = detail or self.default_detail + + class PermissionDenied(APIException): status_code = status.HTTP_403_FORBIDDEN default_detail = 'You do not have permission to perform this action.' |
