Opened 7 years ago

Closed 5 years ago

#6273 closed (fixed)

Support for passwd-like password changing

Reported by: toxik Owned by: justinlilly
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 toxik 7 years ago.
django_auth_passwd_command.diff (6.7 KB) - added by toxik 7 years ago.
6273_django_auth_passwd_command_r2.diff (1.5 KB) - added by justinlilly 6 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 justinlilly 6 years ago.
Now with docs and renamed to change_password

Download all attachments as: .zip

Change History (18)

Changed 7 years ago by toxik

comment:1 Changed 7 years ago by adrian

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to adrian
  • Patch needs improvement set
  • Status changed from new to assigned

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 7 years ago by adrian

  • Owner changed from adrian to nobody
  • Status changed from assigned to new

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

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

  • Triage Stage changed from Unreviewed to Accepted

Changed 7 years ago by toxik

comment:4 Changed 7 years ago by toxik

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 7 years ago by toxik

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 6 years ago by justinlilly

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

comment:6 Changed 6 years ago by justinlilly

  • Cc justinlilly@… added

comment:7 Changed 6 years ago by justinlilly

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 6 years ago by toxik

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 6 years ago by justinlilly

  • Owner changed from nobody to justinlilly

Sure. I'll take this.

comment:10 Changed 6 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 6 years ago by justinlilly

Now with docs and renamed to change_password

comment:11 Changed 6 years ago by justinlilly

  • 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 6 years ago by justinlilly

  • 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 6 years ago by SmileyChris

  • 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 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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