Re: AbstractBaseUser.set_unusable_password() why a random string instead of an empty string?

2016-10-19 Thread Jon Dufresne
Thanks Ramiro and Alex. That does clear it up and helps.

I withdraw the suggestion.

On Wed, Oct 19, 2016 at 7:02 PM, Alexander Hill  wrote:

> Hi Jon,
>
> Here's the ticket where this was proposed: https://code.djangoproject.
> com/ticket/20079
>
> And the commit that implements it: https://github.com/django/
> django/commit/aeb1389442d0f9669edf6660b747fd10693b63a7
>
> Cheers,
> Alex
>
>
> On Thu, 20 Oct 2016 at 08:20 Jon Dufresne  wrote:
>
> When set_unusable_password() is called on a user object, the user's
> password is set to a random string starting with "!" [0]. The "!" is then
> used by is_password_usable() [1] to determine that this password isn't
> usable.
>
> My question is, why is a random string used instead of an empty string? An
> empty string would appear to make the code both simpler and slightly more
> efficient. Is the random string more secure or solving some other issue I'm
> not aware of?
>
> I tested this idea and all tests pass: https://github.com/jdufresne/
> django/commit/2332194b449fe4a336c8ea515221955ba0ea3aeb
>
> The change is relatively easy as all interactions with unusable passwords
> are nicely abstracted by functions
>
> Thoughts on me following through with this code simplification?
>
> [0] https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dc
> a0181e7b3c/django/contrib/auth/hashers.py#L78
> [1] https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dc
> a0181e7b3c/django/contrib/auth/hashers.py#L27
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/CADhq2b7v6BxetkaS6GOW5%3DO1EoXFX9Ke1FWzmCLUs%
> 3DLDjQ5DsA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/CA%2BKBOKySg7uPpgYDXJ9aq0gL92-
> bztoZ5FwKbXyNXPDi4yeqng%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CADhq2b5CZNTaoHktp6tEq3LQ2dEGO00rcQmRXn4o8SpV8WcDPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: AbstractBaseUser.set_unusable_password() why a random string instead of an empty string?

2016-10-19 Thread Ramiro Morales
On Wed, Oct 19, 2016 at 9:20 PM, Jon Dufresne 
wrote:

> When set_unusable_password() is called on a user object, the user's
> password is set to a random string starting with "!" [0]. The "!" is then
> used by is_password_usable() [1] to determine that this password isn't
> usable.
>
> My question is, why is a random string used instead of an empty string? An
> empty string would appear to make the code both simpler and slightly more
> efficient. Is the random string more secure or solving some other issue I'm
> not aware of?
>
> I tested this idea and all tests pass: https://github.com/jdufresne/
> django/commit/2332194b449fe4a336c8ea515221955ba0ea3aeb
>
> The change is relatively easy as all interactions with unusable passwords
> are nicely abstracted by functions
>
> Thoughts on me following through with this code simplification?
>
> [0] https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dc
> a0181e7b3c/django/contrib/auth/hashers.py#L78
> [1] https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dc
> a0181e7b3c/django/contrib/auth/hashers.py#L27
>
>
Quick perusal if the history and blame log of that file reveals some
interesting data:

https://github.com/django/django/commit/2c4fe761a0e2b28e2c5c3b4bc506ee06824a443d

https://github.com/django/django/commit/aeb1389442d0f9669edf6660b747fd10693b63a7
and its associated ticket #20079

I suspect the answer to your quesin lies somewhere ther.

Regards,

-- 
Ramiro Morales
@ramiromorales

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAO7PdF8vSz6j-oSHAWhg84noa1jVyRSjDZC9Da6RqWLi4d3%2Bxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: AbstractBaseUser.set_unusable_password() why a random string instead of an empty string?

2016-10-19 Thread Alexander Hill
Hi Jon,

Here's the ticket where this was proposed:
https://code.djangoproject.com/ticket/20079

And the commit that implements it:
https://github.com/django/django/commit/aeb1389442d0f9669edf6660b747fd10693b63a7

Cheers,
Alex


On Thu, 20 Oct 2016 at 08:20 Jon Dufresne  wrote:

When set_unusable_password() is called on a user object, the user's
password is set to a random string starting with "!" [0]. The "!" is then
used by is_password_usable() [1] to determine that this password isn't
usable.

My question is, why is a random string used instead of an empty string? An
empty string would appear to make the code both simpler and slightly more
efficient. Is the random string more secure or solving some other issue I'm
not aware of?

I tested this idea and all tests pass:
https://github.com/jdufresne/django/commit/2332194b449fe4a336c8ea515221955ba0ea3aeb

The change is relatively easy as all interactions with unusable passwords
are nicely abstracted by functions

Thoughts on me following through with this code simplification?

[0]
https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dca0181e7b3c/django/contrib/auth/hashers.py#L78
[1]
https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dca0181e7b3c/django/contrib/auth/hashers.py#L27

-- 
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/CADhq2b7v6BxetkaS6GOW5%3DO1EoXFX9Ke1FWzmCLUs%3DLDjQ5DsA%40mail.gmail.com

.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CA%2BKBOKySg7uPpgYDXJ9aq0gL92-bztoZ5FwKbXyNXPDi4yeqng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


AbstractBaseUser.set_unusable_password() why a random string instead of an empty string?

2016-10-19 Thread Jon Dufresne
When set_unusable_password() is called on a user object, the user's
password is set to a random string starting with "!" [0]. The "!" is then
used by is_password_usable() [1] to determine that this password isn't
usable.

My question is, why is a random string used instead of an empty string? An
empty string would appear to make the code both simpler and slightly more
efficient. Is the random string more secure or solving some other issue I'm
not aware of?

I tested this idea and all tests pass:
https://github.com/jdufresne/django/commit/2332194b449fe4a336c8ea515221955ba0ea3aeb

The change is relatively easy as all interactions with unusable passwords
are nicely abstracted by functions

Thoughts on me following through with this code simplification?

[0]
https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dca0181e7b3c/django/contrib/auth/hashers.py#L78
[1]
https://github.com/django/django/blob/90c3b11e873a326219a68c14a3b5dca0181e7b3c/django/contrib/auth/hashers.py#L27

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CADhq2b7v6BxetkaS6GOW5%3DO1EoXFX9Ke1FWzmCLUs%3DLDjQ5DsA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.