根据 PhPbb 数据库对用户进行身份验证
最近我开始实现一个解决方案,该解决方案将使用 PhPbb 数据库进行表单授权,我使用了以下线程中的类:
所以我在 'ValidateUser' 函数中使用此类编写了一个会员提供程序:
public override bool ValidateUser(string username, string password)
{
ForumsDataContext db = Root.ForumsDataContext;
PhPbbCryptoServiceProvider phpbbCrypt = new PhPbbCryptoServiceProvider();
string remoteHash = db.Users.Where(u => u.UserName == username).FirstOrDefault().UserPassword;
if (String.IsNullOrEmpty(remoteHash))
return false;
return phpbbCrypt.phpbbCheckHash(password, remoteHash);
}
但是,这总是返回 false,因为 'phpbbCrypt.phpbbCheckHash' 返回 false我对 PhPbb 的了解还不够,无法确定哈希值不匹配的原因。
有什么建议吗?
Recently I have started implementing a solution which will use a PhPbb database for forms authorization, I have used the class from this below thread:
So i wrote a membership provider using this class in the 'ValidateUser' function:
public override bool ValidateUser(string username, string password)
{
ForumsDataContext db = Root.ForumsDataContext;
PhPbbCryptoServiceProvider phpbbCrypt = new PhPbbCryptoServiceProvider();
string remoteHash = db.Users.Where(u => u.UserName == username).FirstOrDefault().UserPassword;
if (String.IsNullOrEmpty(remoteHash))
return false;
return phpbbCrypt.phpbbCheckHash(password, remoteHash);
}
However this always returns false as the 'phpbbCrypt.phpbbCheckHash' returns false and I do not know enough about PhPbb to determine why the hashes are not matching up.
Any sugestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您从 2.0 升级了 phpbb 安装,则密码哈希函数会有所不同。我从 phpbb 中的functions.php 中获取了这个片段(参见: GitHub) 这是整个密码检查和哈希函数,最后有一点输出 phpbb 哈希密码。
这里重要的一点是它不是直接的 MD5。我从 OP 提供的链接中获取了 C# 类,并制作了这个测试类。
这是 OP 问题中的类的修改副本。这将检查旧密码,这些密码只是不加盐的明文密码的 MD5 哈希值,并且我还添加了允许的前缀“$P$”。
If you upgraded your phpbb install from 2.0 the password hashing function is different. I took this snippet from functions.php in phpbb (See: GitHub) this is the entire password checking and hashing functions with a little bit at the end to output a phpbb hashed password.
Important part here is that it isn't a straight MD5. I took the C# class from the link the OP provided and made this test class.
This is a modified copy of the class in the OP question. This will check older passwords which were just an MD5 hash of the plaintext password without a salt and i also added in the prefix "$P$" to be allowed.