[英]Integrating Auth0 authentication with existing user database
I've a requirement to integrate Auth0 in our project (Reactjs/Hapijs/MySQL). 我需要在我们的项目中集成Auth0(Reactjs / Hapijs / MySQL)。 I checked the documentation and they have many examples and that is great, however, I can't find any related to how exactly do I use my existing user database.
我检查了文档,他们有很多例子,这很好,但是,我找不到任何与我如何使用现有用户数据库有关的信息。
In my application I have users and those users can have one or more projects. 在我的应用程序中,我有用户,这些用户可以有一个或多个项目。 With the authorization that we currently use, a user logs in, I check what projects does he own and send it to the React application.
通过我们当前使用的授权,用户登录,我检查他拥有哪些项目并将其发送到React应用程序。
I am missing a document that explains me how to use Auth0 and still be able to check in my database what projects user owns. 我错过了一个文档,它解释了我如何使用Auth0并仍然可以检查我的数据库用户拥有什么项目。
My idea on how that should work (I might be wrong): 关于它应该如何工作的想法(我可能错了):
Is this how it is supposed to work? 这是它应该如何工作?
There are a few options available for scenarios where you want to integrate Auth0 with applications that already have existing user databases. 对于要将Auth0与已有用户数据库的应用程序集成的方案,有几个选项可用。 You can either:
你可以:
You don't mention it explicitly, but judging from your expected flow it seems you would be wanting to implement the first option. 你没有明确提到它,但从你的预期流量判断,你似乎想要实现第一个选项。 There is specific documentation that you can follow that explain how you can setup your custom database connection, see Authenticate Users with Username and Password using a Custom Database .
您可以按照特定文档说明如何设置自定义数据库连接,请参阅使用自定义数据库对用户名和密码进行身份验证 。 It mentions MySQL, but others database servers are supported and there are many templates that will allow you to quickly setup things.
它提到了MySQL,但是支持其他数据库服务器,并且有许多模板可以让你快速设置。
When you complete this the final flow will be the following: 完成此操作后,最终的流程如下:
The scripts you need to provide are the following, but only one is mandatory: 您需要提供的脚本如下,但只有一个是必需的:
The optional scripts are only required when you want to provide the associated functionality through Auth0 libraries, if only need the login to work then you can skip them. 只有当您想通过Auth0库提供相关功能时才需要可选脚本,如果只需要登录工作,那么您可以跳过它们。 The login script, in the case of a valid user, is also where you return the profile information of the user, for example, you could in theory include their owned projects in the user profile.
对于有效用户,登录脚本也是您返回用户的配置文件信息的位置,例如,理论上您可以在用户配置文件中包含其拥有的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.