[Django] #27292: Improve example code in the "Writing an authentication backend" of the documentation

20 views
Skip to first unread message

Django

unread,
Sep 29, 2016, 4:11:30 AM9/29/16
to django-...@googlegroups.com
#27292: Improve example code in the "Writing an authentication backend" of the
documentation
--------------------------------------+--------------------
Reporter: Attila-Mihaly Balazs | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
Link: https://docs.djangoproject.com/en/1.10/topics/auth/customizing
/#writing-an-authentication-backend

It currently says:

...
# Create a new user. Note that we can set password
# to anything, because it won't be checked; the password
# from settings.py will.
user = User(username=username, password='get from
settings.py')
....

A better practice would be to call "set_unusable_password()" on the user
object.

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

Django

unread,
Sep 29, 2016, 10:01:20 AM9/29/16
to django-...@googlegroups.com
#27292: Improve example code in the "Writing an authentication backend" of the
documentation
-------------------------------------+-------------------------------------
Reporter: Attila-Mihaly | Owner: nobody
Balazs |
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Could you explain that a bit more? It looks to me like `password='get from
settings.py'` could be `password=settings.ADMIN_PASSWORD`, but I don't
understand why setting an unusable password would be desired.

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

Django

unread,
Oct 1, 2016, 9:09:51 AM10/1/16
to django-...@googlegroups.com
#27292: Example authentication backend doesn't need to set user's password
--------------------------------------+------------------------------------

Reporter: Attila-Mihaly Balazs | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.10
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 Tim Graham):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Proposed patch is attached. Let me know if I missed the reason why
`set_unusable_password()` is useful.

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

Django

unread,
Oct 1, 2016, 9:09:57 AM10/1/16
to django-...@googlegroups.com
#27292: Example authentication backend doesn't need to set user's password
--------------------------------------+------------------------------------
Reporter: Attila-Mihaly Balazs | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.10
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 Tim Graham):

* Attachment "27292.diff" added.

Django

unread,
Oct 4, 2016, 2:03:52 PM10/4/16
to django-...@googlegroups.com
#27292: Example authentication backend doesn't need to set user's password
--------------------------------------+------------------------------------
Reporter: Attila-Mihaly Balazs | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.10
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 Tim Graham <timograham@…>):

In [changeset:"7652f97a5c5af3ed4b5d306e7a7d4db9df93ecf5" 7652f97]:
{{{
#!CommitTicketReference repository=""
revision="7652f97a5c5af3ed4b5d306e7a7d4db9df93ecf5"
[1.10.x] Fixed #27292 -- Removed unnecessary password assignment in auth
backend example.

Backport of e262f002311735869a5d8b0a8f788708322db595 from master
}}}

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

Django

unread,
Oct 4, 2016, 2:03:56 PM10/4/16
to django-...@googlegroups.com
#27292: Example authentication backend doesn't need to set user's password
--------------------------------------+------------------------------------
Reporter: Attila-Mihaly Balazs | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.10

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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"e262f002311735869a5d8b0a8f788708322db595" e262f002]:
{{{
#!CommitTicketReference repository=""
revision="e262f002311735869a5d8b0a8f788708322db595"


Fixed #27292 -- Removed unnecessary password assignment in auth backend
example.
}}}

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

Reply all
Reply to author
Forward
0 new messages