Commit a26f96a
authored
django.contrib.auth: Relax ModelBackend -> BaseBackend (#2141)
`BaseBackend` is the base interface of django backends, `ModelBackend`
has more specific signatures, such as `.authenticate()` including
`username` and `password`, not all authentication backends use those.
For instance, since the `authenticate()` method in BaseBackend already includes
request (`HttpRequest`), it can read a `Bearer` token or cookie, and already accepts
`**kwargs` for additional parameters.
See also:
- BaseBackend: https://github.com/django/django/blob/5.0.6/django/contrib/auth/backends.py#L8-L28
- ModelBackend: https://github.com/django/django/blob/5.0.6/django/contrib/auth/backends.py#L31-L160
- django.contrib.auth.authenticate(): https://github.com/django/django/blob/5.0.6/django/contrib/auth/__init__.py#L65-L93
- Django Docs for "Writing an authentication backend": https://docs.djangoproject.com/en/5.0/topics/auth/customizing/#writing-an-authentication-backend1 parent 5216eaf commit a26f96a
1 file changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
0 commit comments