Secure Password Hashes (phpass) integration for 6.x-1.x
recrit - October 7, 2009 - 18:45
| Project: | Password policy |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Description
This patch makes modifications to use phpass on storage and validation for password history.
Patch is based on #528106: Secure Password Hashes (phpass) integration for constraint_history.php for 5.x-1.x.
Feature not converted: If phpass is enabled, history constraint javascript is disabled since there is no javascript to perform the hashing with phpass. However, on form submission the password is validated correctly and will produce an error if the history constraint is violated.
| Attachment | Size |
|---|---|
| password_policy_phpass_integration-6.x-1.x.patch | 3.7 KB |

#1
patch should be run from your sites/*/modules directory, not the password_policy directory
#2
I have done some testing and cannot get this to work with the phpass... going to revert back to the original storage of md5.
If anybody has better knowledge of how to implement this, please share. I am wondering how the 5.x patch works since this calls the same phpass functions.
#3
re-rolling the patch, it is working correctly now. I needed to fix the validation check in the history constraint function: password_policy_constraint_history_validate. Original patch was hashing when it should have been checking.
#4
changing status back to needs review
#5
It would be nice somehow resolve the history constraint javascript. We have a requirement that all new password validations should happen without a page refresh.
#6
i agree. I looked into it when making the patch and you would need to convert phpass's PasswordHash.php into a js version... which was a little bit more involved than I had time for.
#7
I'm not sure porting PasswordHash.php is necessary, maybe some AJAX could help, don't like the
async: falsepart of attached patch, but this way it fits nicely without a need to change password_policy.js.#8
I always forget about the AJAX approach.
Thanks for the patch update. I tested it and it appears to work correctly on my system. Have you experience any side effects with the synchronous request in your testing?
#9
The problem with synchronous request is that it blocks UI for up to a second, which isn't noticable on a fast server but could be really annoying on slower ones.
Truth be told I considered lack of js support in this patch to be a feature, as the current approach of sending history of hashes embedded in html is IMHO a really bad idea, they are enough of a problem in the database, wouldn't want them laying aroud in browser's cache or being collected by some other user with 'administer users' privilege.
#10
Attached patch makes the request asynchronous and appends to
passwordDescriptionwhen it finishes, providing much better experience. Had to add additional param toevaluatePasswordStrength(), and change howpasswordCheck()was invoked frompasswordDelayedCheck()as context was lost, maybe it should be changed toouterItemElementaltogether, not sure what the intention was, but currently there is separate state kept for each input (password & confirm). Also got rid of the old code because of security implications mentioned in previous post, so now both phpass and plain hashes are checked via AJAX.#11
I believe the loss of context you had describe is happening due to the lax usage of
thisthroughout the original code... usingthisacross function scopes makes my head hurt.I agree this is a better implementation and handling of the historic passwords. I have been using the patch with no issues. Hopefully the module maintainer will implement the new patch in the next release.
#12
Setting to reviewed for non-JS part as i didn't change anything there and it works as described, assuming recrit reviewed JS part. Just added some empty lines.
#13
...and removed some trailing spaces.
#14
I ran into one problem when using with javascript_aggregator. When aggregated and minified, a javascript error is produced due to the newline characters("\n") appended to the end of the lines in
function password_policy_constraint_history_js. Since the original had this as well, I suspect it could also generate such an issue. I removed the newlines and everything worked as expected.#15
JS aggregation doesn't affect inline scripts, so I don't see how it could be the cause of described problem.
Added missing var keyword and throbber.
#16
you're right the aggregation and minification should not affect he inline scripts...
I just tested a different drupal distribution with the "\n" still in the code and it works fine. There must be something crazy going on with the other distribution that I had errors on. Just confusing as to why removing the "\n" fixed the issue.