简体   繁体   English

在快速网关中创建用户

[英]Creating users in express-gateway

Express-gateway has its own consumer management system and an Admin Api for managing user creation, updating, and so on. Express-gateway拥有自己的消费者管理系统和一个Admin Api,用于管理用户的创建,更新等。

According to docs the Admin Api is for internal use and discourages exposing it publicly. 根据文档,Admin Api仅供内部使用,不建议公开公开。 If that's the case, then how does a user get created by a website registration page that has express-gateway as its microservices api gateway? 如果是这样,那么如何将Express Express作为其微服务api网关的网站注册页面创建用户?

What would the request/response sequence be to create a user that is then logged in and authorized to use Apis, for example would this sequence suffice? 创建一个用户然后登录并被授权使用Apis的请求/响应序列是什么,例如,该序列足够吗?

  • Application as consumer creates a user with Post /user with header Authorization: apiKey <app_key:app_secret> 作为使用者的应用程序使用带有标题授权的Post / user创建一个用户:apiKey <app_key:app_secret>

  • Api responds with JWT token for created user that is then used in subsequent request Api使用JWT令牌响应创建的用户,然后在后续请求中使用该令牌

  • User as consumer requests any exposed endpoint it has scope of, with header Authorization: Bearer <user_jwt_token> 作为消费方的用户请求具有其范围的,带有标题授权的任何公开终结点:承载<user_jwt_token>

Once a user is added to the consumer management system, how do those users correspond to data stored in a microservice database? 将用户添加到消费者管理系统后,这些用户如何与微服务数据库中存储的数据相对应? Is there a recommended way to implement this, for example, each microservice db has a user table with a primary id column and another column to store the user's id generated by eg consumer management system? 是否有建议的实现方法,例如,每个微服务db都有一个用户表,该表具有一个主id列和另一个列来存储例如由消费者管理系统生成的用户的id?

that's correct, we do not recommend to expose the Admin API directly to the public. 没错,我们不建议直接向公众公开Admin API。 It should only be used internally. 它只能在内部使用。

The solution you're suggesting is viable. 您建议的解决方案是可行的。 You can either react to a new consumer created in Express Gateway — grab its ID and use that as a reference for your user in your database (Redis has a pub/sub mechanism so you can easily be notified when this happens) or you can also do that from the reverse side: once an users registers on your website you can create the corresponding user in Express Gateway. 您可以对Express Gateway中创建的新使用者做出反应-获取其ID并将其用作数据库中用户的参考(Redis具有pub / sub机制,因此在发生这种情况时可以很容易地收到通知),或者您也可以从相反的方向进行操作:用户在您的网站上注册后,便可以在Express Gateway中创建相应的用户。

I hope that answers your questions! 我希望能回答您的问题!

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

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