You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-58Lines changed: 13 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,30 +10,6 @@ Full documentation for the project is available at [https://www.django-rest-fram
10
10
11
11
---
12
12
13
-
# Funding
14
-
15
-
REST framework is a *collaboratively funded project*. If you use
16
-
REST framework commercially we strongly encourage you to invest in its
17
-
continued development by [signing up for a paid plan][funding].
18
-
19
-
The initial aim is to provide a single full-time position on REST framework.
20
-
*Every single sign-up makes a significant impact towards making that possible.*
21
-
22
-
[![][sentry-img]][sentry-url]
23
-
[![][stream-img]][stream-url]
24
-
[![][spacinov-img]][spacinov-url]
25
-
[![][retool-img]][retool-url]
26
-
[![][bitio-img]][bitio-url]
27
-
[![][posthog-img]][posthog-url]
28
-
[![][cryptapi-img]][cryptapi-url]
29
-
[![][fezto-img]][fezto-url]
30
-
[![][svix-img]][svix-url]
31
-
[![][zuplo-img]][zuplo-url]
32
-
33
-
Many thanks to all our [wonderful sponsors][sponsors], and in particular to our premium backers, [Sentry][sentry-url], [Stream][stream-url], [Spacinov][spacinov-url], [Retool][retool-url], [bit.io][bitio-url], [PostHog][posthog-url], [CryptAPI][cryptapi-url], [FEZTO][fezto-url], [Svix][svix-url], and [Zuplo][zuplo-url].
34
-
35
-
---
36
-
37
13
# Overview
38
14
39
15
Django REST framework is a powerful and flexible toolkit for building Web APIs.
@@ -54,8 +30,8 @@ Some reasons you might want to use REST framework:
54
30
55
31
# Requirements
56
32
57
-
* Python 3.9+
58
-
* Django 4.2, 5.0, 5.1, 5.2
33
+
* Python 3.10+
34
+
* Django 4.2, 5.0, 5.1, 5.2, 6.0
59
35
60
36
We **highly recommend** and only officially support the latest patch release of
61
37
each Python and Django series.
@@ -67,10 +43,11 @@ Install using `pip`...
67
43
pip install djangorestframework
68
44
69
45
Add `'rest_framework'` to your `INSTALLED_APPS` setting.
46
+
70
47
```python
71
48
INSTALLED_APPS= [
72
-
...
73
-
'rest_framework',
49
+
#...
50
+
"rest_framework",
74
51
]
75
52
```
76
53
@@ -99,7 +76,7 @@ from rest_framework import routers, serializers, viewsets
Copy file name to clipboardExpand all lines: docs/api-guide/authentication.md
+23-27Lines changed: 23 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,13 +19,10 @@ The `request.user` property will typically be set to an instance of the `contrib
19
19
20
20
The `request.auth` property is used for any additional authentication information, for example, it may be used to represent an authentication token that the request was signed with.
21
21
22
-
---
23
-
24
-
**Note:** Don't forget that **authentication by itself won't allow or disallow an incoming request**, it simply identifies the credentials that the request was made with.
22
+
!!! note
23
+
Don't forget that **authentication by itself won't allow or disallow an incoming request**, it simply identifies the credentials that the request was made with.
25
24
26
-
For information on how to set up the permission policies for your API please see the [permissions documentation][permission].
27
-
28
-
---
25
+
For information on how to set up the permission policies for your API please see the [permissions documentation][permission].
29
26
30
27
## How authentication is determined
31
28
@@ -122,17 +119,15 @@ Unauthenticated responses that are denied permission will result in an `HTTP 401
122
119
123
120
WWW-Authenticate: Basic realm="api"
124
121
125
-
**Note:** If you use `BasicAuthentication` in production you must ensure that your API is only available over `https`. You should also ensure that your API clients will always re-request the username and password at login, and will never store those details to persistent storage.
122
+
!!! note
123
+
If you use `BasicAuthentication` in production you must ensure that your API is only available over `https`. You should also ensure that your API clients will always re-request the username and password at login, and will never store those details to persistent storage.
126
124
127
125
## TokenAuthentication
128
126
129
-
---
130
-
131
-
**Note:** The token authentication provided by Django REST framework is a fairly simple implementation.
132
-
133
-
For an implementation which allows more than one token per user, has some tighter security implementation details, and supports token expiry, please see the [Django REST Knox][django-rest-knox] third party package.
127
+
!!! note
128
+
The token authentication provided by Django REST framework is a fairly simple implementation.
134
129
135
-
---
130
+
For an implementation which allows more than one token per user, has some tighter security implementation details, and supports token expiry, please see the [Django REST Knox][django-rest-knox] third party package.
136
131
137
132
This authentication scheme uses a simple token-based HTTP Authentication scheme. Token authentication is appropriate for client-server setups, such as native desktop and mobile clients.
138
133
@@ -173,11 +168,8 @@ The `curl` command line tool may be useful for testing token authenticated APIs.
173
168
174
169
curl -X GET http://127.0.0.1:8000/api/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
175
170
176
-
---
177
-
178
-
**Note:** If you use `TokenAuthentication` in production you must ensure that your API is only available over `https`.
179
-
180
-
---
171
+
!!! note
172
+
If you use `TokenAuthentication` in production you must ensure that your API is only available over `https`.
181
173
182
174
### Generating Tokens
183
175
@@ -293,7 +285,8 @@ Unauthenticated responses that are denied permission will result in an `HTTP 403
293
285
294
286
If you're using an AJAX-style API with SessionAuthentication, you'll need to make sure you include a valid CSRF token for any "unsafe" HTTP method calls, such as `PUT`, `PATCH`, `POST` or `DELETE` requests. See the [Django CSRF documentation][csrf-ajax] for more details.
295
287
296
-
**Warning**: Always use Django's standard login view when creating login pages. This will ensure your login views are properly protected.
288
+
!!! warning
289
+
Always use Django's standard login view when creating login pages. This will ensure your login views are properly protected.
297
290
298
291
CSRF validation in REST framework works slightly differently from standard Django due to the need to support both session and non-session based authentication to the same views. This means that only authenticated requests require CSRF tokens, and anonymous requests may be sent without CSRF tokens. This behavior is not suitable for login views, which should always have CSRF validation applied.
299
292
@@ -334,11 +327,8 @@ You *may* also override the `.authenticate_header(self, request)` method. If im
334
327
335
328
If the `.authenticate_header()` method is not overridden, the authentication scheme will return `HTTP 403 Forbidden` responses when an unauthenticated request is denied access.
336
329
337
-
---
338
-
339
-
**Note:** When your custom authenticator is invoked by the request object's `.user` or `.auth` properties, you may see an `AttributeError` re-raised as a `WrappedAttributeError`. This is necessary to prevent the original exception from being suppressed by the outer property access. Python will not recognize that the `AttributeError` originates from your custom authenticator and will instead assume that the request object does not have a `.user` or `.auth` property. These errors should be fixed or otherwise handled by your authenticator.
340
-
341
-
---
330
+
!!! note
331
+
When your custom authenticator is invoked by the request object's `.user` or `.auth` properties, you may see an `AttributeError` re-raised as a `WrappedAttributeError`. This is necessary to prevent the original exception from being suppressed by the outer property access. Python will not recognize that the `AttributeError` originates from your custom authenticator and will instead assume that the request object does not have a `.user` or `.auth` property. These errors should be fixed or otherwise handled by your authenticator.
342
332
343
333
## Example
344
334
@@ -426,6 +416,11 @@ HTTP Signature (currently a [IETF draft][http-signature-ietf-draft]) provides a
426
416
427
417
[Djoser][djoser] library provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation. The package works with a custom user model and uses token-based authentication. This is a ready to use REST implementation of the Django authentication system.
428
418
419
+
## DRF Auth Kit
420
+
421
+
[DRF Auth Kit][drf-auth-kit] library provides a modern REST authentication solution with JWT cookies, social login, multi-factor authentication, and comprehensive user management. The package offers full type safety, automatic OpenAPI schema generation with DRF Spectacular. It supports multiple authentication types (JWT, DRF Token, or Custom) and includes built-in internationalization for 50+ languages.
422
+
423
+
429
424
## django-rest-auth / dj-rest-auth
430
425
431
426
This library provides a set of REST API endpoints for registration, authentication (including social media authentication), password reset, retrieve and update user details, etc. By having these API endpoints, your client apps such as AngularJS, iOS, Android, and others can communicate to your Django backend site independently via REST APIs for user management.
@@ -454,9 +449,9 @@ There are currently two forks of this project.
454
449
455
450
More information can be found in the [Documentation](https://django-rest-durin.readthedocs.io/en/latest/index.html).
456
451
457
-
##django-pyoidc
452
+
##django-pyoidc
458
453
459
-
[dango-pyoidc][django_pyoidc] adds support for OpenID Connect (OIDC) authentication. This allows you to delegate user management to an Identity Provider, which can be used to implement Single-Sign-On (SSO). It provides support for most uses-cases, such as customizing how token info are mapped to user models, using OIDC audiences for access control, etc.
454
+
[django_pyoidc][django-pyoidc] adds support for OpenID Connect (OIDC) authentication. This allows you to delegate user management to an Identity Provider, which can be used to implement Single-Sign-On (SSO). It provides support for most uses-cases, such as customizing how token info are mapped to user models, using OIDC audiences for access control, etc.
460
455
461
456
More information can be found in the [Documentation](https://django-pyoidc.readthedocs.io/latest/index.html).
462
457
@@ -497,4 +492,5 @@ More information can be found in the [Documentation](https://django-pyoidc.readt
0 commit comments