【问题标题】:Kong custom auth layer and rate limitingKong 自定义身份验证层和速率限制
【发布时间】:2020-08-05 15:49:43
【问题描述】:

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

用户在请求 kong 网关时从 idm 中获取一个 token 并放入 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 来限制速率限制?

我已经找到了:

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

【问题讨论】:

    标签: kong kong-plugin


    【解决方案1】:

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

    【讨论】:

    • 如何在请求标头中添加/附加 user_id?我用 GoLang 写了一个 kong 插件
    • kong.ServiceRequest.SetHeader 应该这样做
    猜你喜欢
    • 1970-01-01
    • 2018-01-19
    • 2020-04-01
    • 2022-12-10
    • 1970-01-01
    • 2023-01-22
    • 2018-07-22
    • 2018-09-26
    • 2010-12-17
    相关资源
    最近更新 更多