While migrating accounts from one system to another it is always good idea to keep the passwords intact. This means you can save users from needing to reset their passwords on the new system. Instead they will just keep using the old ones seamlessly. This can be a huge advantage when you scale up on projects that could have hundreds and hundreds of users.
In this article we will migrate hashes from Open EdX (Django based application) to Symfony 3.
Django stores passwords in following fashion:
Full documentation: https://docs.djangoproject.com/en/1.10/topics/auth...
In this example the passwords looked like:
Note: all passwords were sha256 with 20000 repeats.
In order to support this hashing we need to add new Symfony encoder. The security.yml looks like this:
I am using FOS User Bundle for authentication. User object was already customized, so I only added another custom property ‘encoder’.
Then during authentication process Symfony checks if User implements Symfony\Component\Security\Core\Encoder\EncoderAwareInterface interface, then method getEncoderName() called to get the encoder.
In my case method looks like:
During the import of users I parsed Django’s hash into FOS User’s salt and password and set property encoder to ‘edx’.
This ensures all Django imported users have ‘edx’ encoder, and this is sufficient to allow Django users to login to Symfony using their old passwords.
Please let me know if you have any questions about hashing for your project, I am happy to assist. Email: firstname.lastname@example.org.