(MODULES-1737) Add pw_hash() function#408
Conversation
25dcef9 to
3a75f94
Compare
|
Tests added. |
3a75f94 to
b20ee53
Compare
|
Rebased onto master, so tests should pass soon. |
|
Please update to have graceful failure on unsupported platforms for this function. They way it is currently written if attempted on Windows it will fail hard. |
There was a problem hiding this comment.
Why is this not just module String def crypt ... or something?
There was a problem hiding this comment.
I could change it to that. It was based on some code I found elsewhere to work around this issue.
|
@cyberious I'm not sure what you mean. Ruby provides a basic implementation of |
b20ee53 to
3906d21
Compare
There was a problem hiding this comment.
We salt everywhere. See line 42. This just checks for a faulty String#crypt implementation that doesn't support extended hashes, which is known to exist in older versions of JRuby, and overrides it with a proper Java implementation of crypt(). This weak implementation also exists on MRI on Windows, but we don't have a proper Java implementation under that scenario. I could change this to fail if the implementation is weak and we're not on Java, though. That seems like it would probably be a good idea.
|
Documentation and checking for unsupported platforms has been added. Working on a spec test for unsupported platforms now. |
7070f18 to
865d815
Compare
|
Spec test is in. Pinging @daenney, @cyberious, and @hunner for review. If the review is positive, I'll squash the commits together. |
There was a problem hiding this comment.
why do we even implement hashes which we don't recommend?
why not make this the third, optional argument?
There was a problem hiding this comment.
There's a difference between "you shouldn't use this" and "we recommend you to use the strongest one".
865d815 to
b46be2d
Compare
b46be2d to
d1b6dfa
Compare
|
Rebased onto master and squashed. |
There was a problem hiding this comment.
Can we do this the other way around?
User-understanding wise I much prefer: pw_hash('lalalala', 'sha-256', 'oseatnoirsentaiore') over pw_hash('lalalala', '5', 'oseatnoirsentaiore').
The first case I can immediately see what's going on. The second case I need to look up some implementation detail around specifiers to understand what type of hash this function call will be computing.
There was a problem hiding this comment.
Sure. Give me a few minutes to make the change.
d1b6dfa to
e20b978
Compare
|
@daenney How's it look now? |
|
Much better but the tests are red.
|
101a48b to
23be402
Compare
|
@daenney I knew I forgot to do something! Fixed. |
|
@hunner @cyberious I'm okay with this. Up to you now. |
(MODULES-1737) Add pw_hash() function
As per MODULES-1737, this PR provides a method of generating password hashes. Tests coming.