validate-jwt Azure策略表达式性能问题

问题描述

我们的所有Azure API中都包含以下代码段,这用于验证用户令牌。但是,我们观察到的是,每次执行API时(有时非常快),都在openid config url中调用url。不确定确切如何工作。

<validate-jwt header-name="Authorization" Failed-validation-httpcode="401" Failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
  <openid-config url="https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/.well-kNown/openid-configuration" />
  <required-claims>
    <claim name="aud">
      <value>{{clientId}}</value>
    </claim>
  </required-claims>
</validate-jwt>

以下是当我们在Azure门户中的Azure APIM测试功能中运行时的屏幕截图。有时需要200毫秒,有些时候是随机

enter image description here

从我们的日志中,我们观察到顺序耗时约250毫秒,并导致所有API出现性能问题。 enter image description here

一个简单的解决方法是在进入令牌验证时在我们的服务中实施如下所示的内容,但我们担心的是我们不想陷入单点故障并无法解决这种单独服务的问题。

JWT Validation: Caching JWKS derived from cached discovery document via Azure API Management

对于深入了解validate-jwt策略或更好的主意的任何指针,将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)