简体   繁体   English

生成user_password phpBB

[英]Generate user_password phpBB

I have a gameserver running on the same server as a phpBB forum. 我有一个与phpBB论坛在同一服务器上运行的gameserver。

I want to make users verify their identity to the gameserver by entering their phpBB username and password. 我想通过输入phpBB用户名和密码来使用户向游戏服务器验证其身份。

I know how to do this with their username (simply get their username and compare it to the 'username' field in the SQL database.) 我知道如何使用其用户名(只需获取其用户名,并将其与SQL数据库中的“用户名”字段进行比较。)

However, I'm not sure how to encrypt the entered password so that I can compare it to the 'user_password' field. 但是,我不确定如何加密输入的密码,以便可以将其与“ user_password”字段进行比较。 If it requires md5, I'd prefer to use the md5() function in SQL but I can do it outside of SQL. 如果它需要md5,我希望在SQL中使用md5()函数,但是我可以在SQL之外使用它。

Apparently, phpBB uses phpass for its password management. 显然,phpBB使用phpass进行密码管理。 That's actually quite good, as it means that there's a good chance you're using a standard password hashing algorithm like bcrypt under the covers. 这实际上是相当不错的,因为这意味着您很有可能在幕后使用诸如bcrypt之类的标准密码哈希算法。 Bcrypt is considered to be very strong. Bcrypt被认为是非常强大的。

To work out whether a password matches a bcrypted hash, you (logically) retrieve the encoded hash string, get the cost parameter and salt out of it, and then see if (when you apply the bcrypt algorithm to the submitted password, the cost and the salt) it results in the same actual hash bytes as you retrieved. 要确定密码是否与bcrypted哈希匹配,您(在逻辑上)检索编码的哈希字符串,获取cost参数并对其进行盐析,然后查看(将bcrypt算法应用于所提交的密码时,cost和盐),结果将与您检索到的实际哈希字节相同。 It's computationally expensive (and the hashing algorithm itself is tricky if you're implementing from scratch, which it is suggested you don't do) but it's not logically all that complicated to the outside world. 它的计算量很大(如果您是从头开始实现的,那么哈希算法本身就很棘手,建议您要这样做),但是从逻辑上讲,这对于外部世界来说并没有那么复杂。

It might be worthwhile putting the code to do the verification in PHP and doing the verification by a local web service call, since then you can easily leverage the existing code (like that, you can definitely match what the user credential handling is). 可能值得将代码放在PHP中进行验证,并通过本地Web服务调用进行验证,因为这样您就可以轻松利用现有代码(这样,您就可以肯定用户凭证处理的内容)。 Probably make it be a page that just returns the “current” user name after processing a log in, and make the client of this not maintain session state. 可能使它成为仅在处理登录后返回“当前”用户名的页面,并使该客户机不保持会话状态。 (That should be trivial.) You might need to think in terms of locking the page from access from off the machine, and adding some sort of rate limiting too (eg, only one response per user from this special page per 10 seconds) as that makes impractical all sorts of nasty tricks. (这应该是微不足道的。)您可能需要考虑锁定页面以防止从计算机外访问该页面,并且还添加了某种速率限制(例如,每10秒每个用户对该特殊页面只有一个响应):这使各种不实际的恶作剧变得不切实际。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM