Hey Daniel,
This doesn’t look right unfortunately but it is a good start.
The goal here is not to return the hash but to validate if the password provided is correct.
Inevitably checking that the hash that you generate in this function, matches the hash that is stored in your database.
The salt is not $hashFromDatabase. It is something that will be unique to your external system. In some systems every user has their own salt (the most secure way of doing it) and in some systems there is one salt for all systems.
You’ll have to research your system to find out what it uses for salting passwords when hashing.
Your end solution will look something like this:
function myExlogHashAuthenticator($password, $hashFromDatabase, $username, $externalUserData) {
return sha1(md5($password) . 'someSaltHere') === $hashFromDatabase;
}
add_filter('exlog_hook_filter_authenticate_hash', 'myExlogHashAuthenticator', 10, 4);
If you’re confused about what a salt is and this is not making sense I would strongly recommend this article:
https://martinfowler.com/articles/web-security-basics.html
Skip to the title: “Hash and Salt Your Users’ Passwords”
Hope this helps ??
-
This reply was modified 4 years, 5 months ago by tbenyon.