Opened 9 years ago

Closed 7 years ago

#6273 closed (fixed)

Support for passwd-like password changing

Reported by: Ludvig Ericson Owned by: Justin Lilly
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: justinlilly@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:

Description

I wrote a short command handler for management to change the password of the current user, or a given user, just like passwd.

Attachments (4)

django-passwd.diff (1.4 KB) - added by Ludvig Ericson 9 years ago.
django_auth_passwd_command.diff (6.7 KB) - added by Ludvig Ericson 9 years ago.
6273_django_auth_passwd_command_r2.diff (1.5 KB) - added by Justin Lilly 8 years ago.
Applies cleanly to r9478 -- Removed all changes except passwd.py which works.
6273_change_password_auth_command.diff (2.3 KB) - added by Justin Lilly 7 years ago.
Now with docs and renamed to change_password

Download all attachments as: .zip

Change History (18)

Changed 9 years ago by Ludvig Ericson

Attachment: django-passwd.diff added

comment:1 Changed 9 years ago by Adrian Holovaty

Needs documentation: unset
Needs tests: unset
Owner: changed from nobody to Adrian Holovaty
Patch needs improvement: set
Status: newassigned

This is a good idea, but a key improvement needs to be made before we can check it in. Because Django's auth system is technically a contrib app, this command should live in the django/contrib/auth directory. The advantages of this are that it won't clutter the django-admin.py command namespace if the auth app isn't installed, and it keeps all of the auth code together in the same subpackage.

Could you rework the patch to do this? Here's some documentation on how applications can specify custom django-admin.py actions: http://www.djangoproject.com/documentation/django-admin/#customized-actions

comment:2 Changed 9 years ago by Adrian Holovaty

Owner: changed from Adrian Holovaty to nobody
Status: assignednew

Ack, I didn't mean to accept the ticket -- hopefully toxik will be able to code up the patch.

comment:3 Changed 9 years ago by Simon Greenhill <dev@…>

Triage Stage: UnreviewedAccepted

Changed 9 years ago by Ludvig Ericson

comment:4 Changed 9 years ago by Ludvig Ericson

Okay, sorry for the delay, but I fixed it. Works for me, but I had to make management.py a package, so I don't know if that has any side-effects. (Moved it to ./management/__init__.py, should be fine I suppose.)

Also note that you want to delete the old management.py file since I doubt the patch will do that.

comment:5 Changed 9 years ago by Ludvig Ericson

Oh and I changed the command a lil' bit, now it aborts if any of the two inputs are empty rather than if any are empty after both have been answered.

Also I'd like to post this svn st so as to clarify what I meant:

D      django/contrib/auth/management.py
A      django/contrib/auth/management
A      django/contrib/auth/management/commands
A      django/contrib/auth/management/commands/__init__.py
A      django/contrib/auth/management/commands/passwd.py
A      django/contrib/auth/management/__init__.py

Changed 8 years ago by Justin Lilly

Applies cleanly to r9478 -- Removed all changes except passwd.py which works.

comment:6 Changed 8 years ago by Justin Lilly

Cc: justinlilly@… added

comment:7 Changed 8 years ago by Justin Lilly

This functionality is available via django-command-extensions http://code.google.com/p/django-command-extensions/ Not sure if it should be wontfix'd as its available as a 3rd party app, especially since adrian was in favor. That being said, adrian was in favor before django-command-extensions existed. Hopefully someone with a better grasp on this stuff can decide?

comment:8 Changed 8 years ago by Ludvig Ericson

Well, it's in django-command-extensions because I put it there. :-)

I think something like this should be available so that you don't have to force system administrators to either update a user's password using a Python shell or by means of the admin.

As an aside, would you (justinlilly) care to maintain this one? It'd be nice as I don't have the time over that I used to, what with the real world and that.

comment:9 Changed 8 years ago by Justin Lilly

Owner: changed from nobody to Justin Lilly

Sure. I'll take this.

comment:10 Changed 8 years ago by Jacob

Needs documentation: set
Needs tests: set

Before this can go in:

  • passwd is a bit inside-baseball-y. Is there something wrong with change_password?
  • Needs documentation.
  • Needs tests.

Changed 7 years ago by Justin Lilly

Now with docs and renamed to change_password

comment:11 Changed 7 years ago by Justin Lilly

Needs documentation: unset

Added docs and changed passwd to change_password. Will need to do some more digging on the proper way to test these sorts of scripts.

comment:12 Changed 7 years ago by Justin Lilly

Needs tests: unset
Patch needs improvement: unset

Russel has given me special dispensation for making this patch a "manual test" due to the complications for testing it. Should be ready for review, then check in.

comment:13 Changed 7 years ago by Chris Beaven

Needs tests: set

It's not that complicated: monkeypatch the _get_pass method in your tests to return what you want without prompting.

comment:14 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [12351]) Fixed #6273 -- Added a 'changepassword' management command. Thanks to Ludvig Ericson and Justin Lilly for their work on this patch.

Note: See TracTickets for help on using tickets.
Back to Top