1

我想使用 Kong 来保护一些服务。但我已经使用 idm 进行用户管理。

用户从 idm 获取令牌,并在请求 kong 网关时将其放入 header 中。为此,我将编写一个插件来执行此操作。然后插件会请求 idm。如果允许用户发出此请求以及用户在 idm 中拥有的用户 ID,则作为您从 idm 获得的答案。所以用户只在idm中注册,而不是在Kong中作为消费者。如果我现在想使用速率限制,插件描述说If the underlying Service/Route (or deprecated API entity) has no authentication layer, the client IP address will be used, otherwise the Consumer will be used if an authentication plugin has been configured.

现在是否可以使用 idm 中的用户 ID 来限制速率限制?

我已经发现:

但我找不到我的问题的答案。

4

1 回答 1

0

您可以将config.limit_by标题设置config.header_name为自定义名称(配置)。所以插件需要为 idm 给出的 id 设置一个自定义标头,例如“x-user-id”。您必须确保您的插件在速率限制插件之前运行。您可以在此处查找(> 901)。现在只需将其设置config.header_name为 x-user-id 和速率限制即可。我找不到其他解决方案。

于 2020-08-06T07:55:00.390 回答