[Django] #30226: Simplify authentication backend interface

11 views
Skip to first unread message

Django

unread,
Feb 28, 2019, 10:36:44 AM2/28/19
to django-...@googlegroups.com
#30226: Simplify authentication backend interface
------------------------------------------------+------------------------
Reporter: Tobias Bengfort | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.auth | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Currently, writing a new authentication backend requires quite some
boilerplate e.g. `has_perm()` can be derived from `get_all_permissions()`
which in turn can be derived from `get_user_permissions()` and
`get_group_permissions()`. Additionally, `authenticate()` and `get_user()`
should always return `None` for backends that only handle permissions.

Also note that `get_all_permissions()` and `get_group_permissions()` exist
on the User model, but `get_user_permissions()` does not. I think this is
confisuing for backend authors.

Mailinglist thread: https://groups.google.com/forum/#!topic/django-
developers/CNmz22gEsCc
Pull request: https://github.com/django/django/pull/11037

--
Ticket URL: <https://code.djangoproject.com/ticket/30226>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 28, 2019, 10:48:13 AM2/28/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------

Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted
* type: Cleanup/optimization => New feature
* version: 2.1 => master
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:1>

Django

unread,
Mar 2, 2019, 4:45:47 AM3/2/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------
Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tobias Bengfort):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:2>

Django

unread,
Mar 8, 2019, 10:08:18 AM3/8/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------
Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1


Comment:

I left a few comments on the PR. When they're addressed, good to go.

--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:3>

Django

unread,
Mar 8, 2019, 10:23:39 AM3/8/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------
Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tobias Bengfort):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:4>

Django

unread,
Mar 8, 2019, 10:24:04 AM3/8/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------
Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Description changed by Tobias Bengfort:

Old description:

> Currently, writing a new authentication backend requires quite some
> boilerplate e.g. `has_perm()` can be derived from `get_all_permissions()`
> which in turn can be derived from `get_user_permissions()` and
> `get_group_permissions()`. Additionally, `authenticate()` and
> `get_user()` should always return `None` for backends that only handle
> permissions.
>
> Also note that `get_all_permissions()` and `get_group_permissions()`
> exist on the User model, but `get_user_permissions()` does not. I think
> this is confisuing for backend authors.
>
> Mailinglist thread: https://groups.google.com/forum/#!topic/django-
> developers/CNmz22gEsCc
> Pull request: https://github.com/django/django/pull/11037

New description:

Currently, writing a new authentication backend requires quite some
boilerplate e.g. `has_perm()` can be derived from `get_all_permissions()`
which in turn can be derived from `get_user_permissions()` and
`get_group_permissions()`. Additionally, `authenticate()` and `get_user()`
should always return `None` for backends that only handle permissions.

Also note that `get_all_permissions()` and `get_group_permissions()` exist
on the User model, but `get_user_permissions()` does not. I think this is

confusing for backend authors.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:5>

Django

unread,
Mar 8, 2019, 10:33:52 AM3/8/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
-------------------------------------+-------------------------------------

Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:6>

Django

unread,
Mar 23, 2019, 5:10:41 PM3/23/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------

Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1

* stage: Ready for checkin => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:7>

Django

unread,
Mar 23, 2019, 8:43:46 PM3/23/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------
Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: new
Component: contrib.auth | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tobias Bengfort):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:8>

Django

unread,
Jun 5, 2019, 8:29:58 AM6/5/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------
Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: closed
Component: contrib.auth | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"581a0f45453f178b8abc0d09bd16ce06309ed33a" 581a0f45]:
{{{
#!CommitTicketReference repository=""
revision="581a0f45453f178b8abc0d09bd16ce06309ed33a"
Refs #30226 -- Added User.get_user_permissions() method.

Added to mirror the existing User.get_group_permissions().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:10>

Django

unread,
Jun 5, 2019, 8:29:58 AM6/5/19
to django-...@googlegroups.com
#30226: Add base authentication backend to ease custom backend creation.
---------------------------------+------------------------------------
Reporter: Tobias Bengfort | Owner: nobody
Type: New feature | Status: closed
Component: contrib.auth | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"75337a60509fdfdd321a5caf8e30d57fff6b9518" 75337a6]:
{{{
#!CommitTicketReference repository=""
revision="75337a60509fdfdd321a5caf8e30d57fff6b9518"
Fixed #30226 -- Added BaseBackend for authentication.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30226#comment:9>

Reply all
Reply to author
Forward
0 new messages