diff options
| author | Tom Christie | 2012-10-17 15:23:36 +0100 | 
|---|---|---|
| committer | Tom Christie | 2012-10-17 15:23:36 +0100 | 
| commit | b78872b7dbb55f1aa2d21f15fbb952f0c7156326 (patch) | |
| tree | 48a6a5568ec91ea52d952caddbed557dc446ad59 /docs/api-guide/authentication.md | |
| parent | a4d500ba107466e8d44a82ed8ca632a3ea81a016 (diff) | |
| download | django-rest-framework-b78872b7dbb55f1aa2d21f15fbb952f0c7156326.tar.bz2 | |
Use two seperate exceptions - `AuthenticationFailed`, and `NotAuthenticated`
Cleaner seperation of exception and resulting HTTP response.
Should result in more obvious error messages.
Diffstat (limited to 'docs/api-guide/authentication.md')
| -rw-r--r-- | docs/api-guide/authentication.md | 4 | 
1 files changed, 2 insertions, 2 deletions
| diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 06f428c0..3ace6519 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -156,12 +156,12 @@ Unauthenticated responses that are denied permission will result in an `HTTP 403  To implement a custom authentication scheme, subclass `BaseAuthentication` and override the `.authenticate(self, request)` method.  The method should return a two-tuple of `(user, auth)` if authentication succeeds, or `None` otherwise. -In some circumstances instead of returning `None`, you may want to raise an `Unauthenticated` exception from the `.authenticate()` method. +In some circumstances instead of returning `None`, you may want to raise an `AuthenticationFailed` exception from the `.authenticate()` method.  Typically the approach you should take is:  * If authentication is not attempted, return `None`.  Any other authentication schemes also in use will still be checked. -* If authentication is attempted but fails, raise an `Unauthenticated` exception.  An error response will be returned immediately, without checking any other authentication schemes. +* If authentication is attempted but fails, raise a `AuthenticationFailed` exception.  An error response will be returned immediately, without checking any other authentication schemes.  You *may* also override the `.authentication_header(self, request)` method.  If implemented, it should return a string that will be used as the value of the `WWW-Authenticate` header in a `HTTP 401 Unauthorized` response. | 
