-
Notifications
You must be signed in to change notification settings - Fork 968
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
feat: support importing MD5 hashes #2725
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2725 +/- ##
=======================================
Coverage 76.10% 76.11%
=======================================
Files 308 308
Lines 18880 18918 +38
=======================================
+ Hits 14369 14399 +30
- Misses 3392 3397 +5
- Partials 1119 1122 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, and thanks a lot for your PR. It looks really good already, I have just left some comments.
You can improve the coverage by adding more test cases to parse for formats that don't match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @erolkskn, LGTM! 🎉
@zepatrik can we merge this now or should we wait for final approval by @aeneasr?
/cc @jonas-jonas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good IMO. We will merge it beginning of next week 👍
Awesome! This is mergable! The last missing piece is no adding a bit of docs for this feature :) https://www.ory.sh/docs/kratos/manage-identities/import-user-accounts-identities#bcrypt-pkbdf2-argon2-scrypt-family-hashed-password We probably need a dedicated section for MD5 as our implementation is not standardized, meaning that we'll need to explain how this works :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful!
Oh sorry for this took too long. I couldn't find appropriate time to write down docs. It should be ready in the next few days. |
Awesome! And there have since been a few merge conflicts - could you please also take a look into those? :) |
Of course :-) Going to look at them as soon as I can today |
c089b34
Thank you! We still need to explain this feature in the documentation. Do you need help for that? :) |
No help needed now, thank you :-) I'm going to create a PR regarding this on "ory/docs" this evening. |
awesome!!! |
Signed-off-by: Erol Keskin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the good work, @erolkskn!
Your welcome :-) |
hi , I am using the "import" command to import the identity, and the password is encrypted using the md5 method. However, I cannot log in correctly. After checking, I found that if the previous password was encrypted using a different programming language, it cannot be properly compared and verified. This is because the md5 encryption method in Go differs from other programming languages (Go uses bytes). However, in older systems, different programming languages such as PHP or C# may have been used. This prevents me from using those md5 passwords for login. In summary, it seems that there are two different md5 encryption methods, and it appears that they are not supported at the moment. Can we open a separate issue to address this matter? |
With which programming language were your passwords hashed before? In theory the implementation in Kratos should follow the spec, but if the passwords were hashed with some custom implementation, that deviates from the spec, Kratos won't be able to verify the passwords. Please also make sure, to include the salt if a salt was used to hash the passwords.
Please do! |
I think I have reached some conclusions. The unit test cases for this PR are incorrect. Taking the first test case as an example, after encrypting with md5 and base64, the expected result should be The reason for this is that the encryption process involves passing the md5Hash := md5.Sum([]byte("test")) // 098f6bcd4621d373cade4e832627b4f6
//use byte[:] to base64 encode (X)
base64Encoded := base64.StdEncoding.EncodeToString(md5Hash[:])
fmt.Println(base64Encoded) //CY9rzUYh03PK3k6DJie09g==
//use string to base64 encode (O)
base64Encoded1 := base64.StdEncoding.EncodeToString([]byte(hex.EncodeToString(md5Hash[:])))
fmt.Println(base64Encoded1) //MDk4ZjZiY2Q0NjIxZDM3M2NhZGU0ZTgzMjYyN2I0ZjY= I will open an issue, and if anyone is willing, please assist in fixing it. 🥲 |
Related issue(s)
#2716
Checklist
If this pull request addresses a security. vulnerability,
I confirm that I got green light (please contact [email protected]) from the maintainers to push the changes.