根据 ASP.NET 成员资格对 Ignite Openfire 用户进行身份验证?
我想知道是否有任何简单的方法可以根据我现有的 ASP.NET 成员身份对 Openfire 用户进行身份验证?我看到 Openfire 有一个自定义数据库集成指南 here 但我不认为它支持我当前的密码安全方法。显然,我的一些成员拥有类型 1 密码安全性,一些成员拥有类型 2 密码安全性。我不确定这是怎么发生的,但由于它们不一致,我无法使用 Openfire 的预设密码安全选项之一。我需要查询数据库以找出密码的存储方式,然后根据类型应用正确的密码身份验证方法。有什么建议吗?
I was wondering if there was any simple way to authenticate Openfire users against my existing ASP.NET membership? I see that Openfire has a custom database integration guide here
but I don't think that it supports my current method of password security. Apparently some of my members have type 1 and some have type 2 password security. I'm not sure how that happened, but since they are inconsistent, I can't use one of Openfire's preset password security options. I'd need to query against my database to figure out how the password is stored and then apply the correct method of password authentication based on the type. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以,让它发挥作用实际上并不难。您需要创建三个新的 Java 文件,每个文件对应以下各项:
实现管理提供程序和用户提供程序很简单,只需遵循提供的 JDBC 示例即可。需要注意的一件事是,IIS 数据库与某些 GUID 无关,而实际的用户帐户字段(电子邮件、姓名等)位于不同的表中,因此您必须执行查询才能找出 IIS ID ,然后用它来计算出帐户字段的其余部分,即。
SELECT TOP 1 UserId FROM dbo.aspnet_Users WHERE LoweredUserName = ?
然后获取电子邮件(在获得 IIS ID 后)
SELECT TOP 1 Email FROM dbo.aspnet_Membership WHERE UserId = ?< /code>
进行实际的身份验证非常简单,只需获取 openfire 给你的用户名,清理它(有时是 user@host - @host部分实际上并不是用户名的一部分)并根据您提供的用户名找出 IIS ID。
然后您可以进行查询来找出密码和密码。密码哈希
SELECT TOP 1 Password, PasswordSalt FROM dbo.aspnet_Membership WHERE UserId = ?
这样,您就拥有了加密提供给您的密码所需的一切 - 这是算法:
注意 - 所有OpenFire 中包含了 utils(即
decodeHex(...)
、Base64...
),只需将此函数的结果与 IIS 进行比较数据库的密码字段,您就可以开始运行了。
管理提供程序需要注意的另一件事是:openfire 使用的 AdminManager 缓存结果。看起来结果在系统启动时就被缓存了——所以实际上不可能使管理员列表与 IIS 保持同步。我仍在仔细考虑这一问题,以找出最好的方法。我可能只是删除所有缓存(AdminManager 仅在内存中保存管理员列表。)
一旦完成所有设置,只需更改 openfire 配置中的一些属性即可将其连接到您的解决方案,例如。
我为 IIS 数据库用户名/密码添加了更多属性,以及一些关于我的管理组名称的变量等。只需遵循 JDBC 示例即可,这非常简单。请注意,在更改 openfire 配置中的
provider.*
属性后,您将无法再使用默认管理员登录 - 如果出现问题,您将不得不返回到数据库并更改配置(在 openfire 数据库的 dbo.ofProperty 表中。)So, it's actually not that hard to get this to work. You need to create three new Java files, one for each of the following:
Implementing the admin provdier and the user provider is straightfoward, just follow the JDBC examples that are provided. One thing to note is that the IIS databse is keyed off of some GUID, and the actual user account fields (E-mail, name, etc) are in a different table, so you have to do a query to figure out the IIS ID, then use that to figure out the rest of the account fields, ie.
SELECT TOP 1 UserId FROM dbo.aspnet_Users WHERE LoweredUserName = ?
Then to get the E-mail (after you have the IIS ID)
SELECT TOP 1 Email FROM dbo.aspnet_Membership WHERE UserId = ?
Doing the actual authentication is very easy, just take the username given to you by openfire, clean it up (it's sometimes user@host -- the @host part is not really part of the username) and figure out the IIS ID based on the username you're given.
Then you can do a query to figure out the password & password hash
SELECT TOP 1 Password, PasswordSalt FROM dbo.aspnet_Membership WHERE UserId = ?
With that you have all you need to encrypt the password that's given to you -- here's the algorithm:
Note -- all of the utils are included with OpenFire (ie.
decodeHex(...)
,Base64...
)Just compare the result of this function with the IIS database's password field and you'll be off and running.
Another thing to note with the Admin provider: the AdminManager that openfire uses caches the results. It looks like the results get cached when the system starts -- so it's not really possible to keep the list of admins in sync with IIS. I'm still mulling over that one to figure out what the best approach will be. I might just remove the caching all together (AdminManager just holds a list of admins in memory.)
Once you get everything setup, just change a few properties in the config for openfire to connect it to your solution, ex.
I added a few more properties for the IIS database username/password as well as some variables for what the name of my admin group is, etc. Just follow the JDBC examples and it's very easy. Note that after you change the
provider.*
properties in the openfire config you won't be able to login with the default admin anymore -- if something is messed up you'll have to go back into the database and change the config (in thedbo.ofProperty
table of your openfire DB.)