1

我如何引用 consumerId 以登录 express-gateway - 例如特定的“元素”是否记录在任何地方?

mytest:
 apiEndpoints:
  - test
 policies:
  - log:
     action:
       message: ${req.consumerId} ${req.ip} ${req.method} ${req.originalUrl}
  - key-auth:
  - proxy:
     action:
      serviceEndpoint: testscore
      changeOrigin: true
      stripPath: true

给我一个空响应

4

2 回答 2

0

它们都放在egContext袋子里。

req.egContext.consumerId

于 2019-11-18T12:54:07.133 回答
0

我可以使用以下方式获取消费者 ID:${egContext.consumer.id} 请注意,它仅在授权策略之后可用,例如:oauth2

于 2020-01-13T21:12:05.313 回答