-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
PasswordEncoder should support BCrypt #5932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@elnur maybe you should simply contribute your encoder to the core for 2.2 ? |
Yea, no problem. I'll do it on this weekend. |
@elnur you want to pair up on this one? I can tie up what we already have in a bow and submit the pull request. Here is the port on your very nice code: I want to review it one more time, and get your go ahead and I'll submit a pull request |
@theoreticaLee, thanks, but I better do it on my own. First of all, I want to rename the encoder and at least one variable. Then, it's not just the encoder that needs to be ported, but the configuration stuff, tests, documentation and changelog need to be added as well. So, just give me a couple of days and I'll do it. ;) |
ok, removed commit. |
If you convert the ElnurBlowfishPasswordEncoderBundle into a Symfony2 default, can you have a look at PERBILITY\BCryptBundle. It's pretty much the same as your bundle, but provides support for a) a global salt which can be defined at application level and b) the possibility to bind the hash to additional user-data (such as email). |
@TerjeBr: it was all already taken care of in my gist. Which is also faster as it uses standard base64. |
@mvrhov I can see at least 2 errors in your getSalt() function. First it requires 18 random bytes instead of 16. |
Now the salt is indeed a bit longer. I'm just making sure that we are not short and at the same time too greedy. |
@mvrhov Have you studied your own code? return substr(hash('sha512', uniqid(mt_rand(), true), true), 0, $nbBytes); When $nbBytes is 16, this will return 16 raw bytes not encoded as anything. That is one error. Your third error is in the above comment. You cannot return the value hex encoded. It will just be interpreted as base64 on the crypt routine all the same, but again you limit the entropy. Only those base64 values that also happen to be valid hex will be used. If you are going to use mt_rand as a fallback, it is best to just use that value directly in your code, as I have done. Also, why not use /dev/urandom as a source if the system has an /dev/urandom? That is the first choice in my code. (And as I said before, please feel free to copy any chunks of code from me.) |
Well, when submitting the encoder, the generation of the salt should use the SecureRandom class anyway instead of trying to duplicate it (and it provides a secure fallback when SSL is disabled) |
Here is my latest version of the code @stof Be aware that the random generation is only one part of my complaint with the code as it stands. |
+1 This needs to be implemented as a matter of priority. Even Zend Framework supports this. |
there is already a PR implementing it (#5974) but it is not ready to be merged yet |
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #6808). Commits ------- 0cb74a2 Added BCrypt password encoder. Discussion ---------- Bcrypt password encoder Bug fix: no Feature addition: yes Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: #5932 License of the code: MIT Documentation PR: symfony/symfony-docs#1936 --------------------------------------------------------------------------- by TerjeBr at 2013-01-19T18:53:21Z Finishing PR #5974 --------------------------------------------------------------------------- by jalliot at 2013-01-20T14:07:54Z This looks very good! :) But be careful to CS or this will not be merged. --------------------------------------------------------------------------- by TerjeBr at 2013-01-20T14:17:35Z I do not understand. What do you mean by "CS"? --------------------------------------------------------------------------- by jalliot at 2013-01-20T14:20:33Z [Coding standards](http://symfony.com/doc/current/contributing/code/standards.html). You should run [PHP-CS-Fixer](https://github.com/fabpot/PHP-CS-Fixer) on your code to fix it. --------------------------------------------------------------------------- by TerjeBr at 2013-01-20T14:47:23Z The only thing php-cs-fixer.phar did was to realign some of the doc-block comments. But thank you any way for pointing out the script to me. --------------------------------------------------------------------------- by TerjeBr at 2013-01-20T15:52:07Z Why does it look like @elnur added the commits? It was me. --------------------------------------------------------------------------- by stof at 2013-01-20T16:32:12Z @TerjeBr check your git configuration to be sure it uses your email address when committing --------------------------------------------------------------------------- by TerjeBr at 2013-01-20T17:30:58Z Now the commit is in my name. But see what happens if I squash the commit wit git rebase .... --------------------------------------------------------------------------- by TerjeBr at 2013-01-20T17:33:08Z Now it looks like elnur added the commit. --------------------------------------------------------------------------- by stof at 2013-01-26T15:57:59Z @fabpot is there a chance to have this in 2.2 ?
see discussion here:
https://groups.google.com/group/symfony-devs/browse_thread/thread/92ae24eafd13e29e?hl=en
The text was updated successfully, but these errors were encountered: