【问题标题】:Istio authservice oidc fails to exchange authorization code for access tokenIstio authservice oidc 无法交换访问令牌的授权码
【发布时间】:2020-07-01 19:15:58
【问题描述】:

我们正在尝试在我们的 k8s 集群中使用 istio 为 authZ 和 authN 设置一个 oidc 提供程序。我们在此处遵循此示例:Bookinfo with Authservice Example 用于集成。 以下是设置的详细信息:

OIDC 提供商:Keycloak
授权类型:authorization_code
Istio 版本:1.5

身份验证流程:

  1. 在第一次请求时,由于没有身份验证,authservice 成功重定向到 Keycloak,我们能够成功登录。
  2. Keycloak 然后将请求重定向到redirect_uri 上的应用程序。授权码现在出现在此 uri 中。
  3. redirect_uri 再次被 authservice 拦截,它检测到 url 是the configmap 中定义的 oidc 的过滤器 url
  4. 现在它尝试调用 keycloak 来交换访问令牌的授权码。

这是 authservice 失败并给出错误IdP connection error 的步骤。请求的日志如下:

Check: processing request ://microservice.url.com/appservice/oauth/callback?state=LeCNEqfwA6EUFGNGLt7JALx8jCWkPxjn7qCELbqkKrk&session_state=18f0e3b0-bee2-44a5-b049-6e349dbeda49&code=ddea1ea6-5616-416d-8291-c00bce6f2e9b.18f0e3b0-bee2-44a5-b049-6e349dbeda49.af7e7c31-fd4b-4a66-9856-25d1ac305d3f with filter chain idp_filter_chain
20/03/2020 17:27:48 [2020-03-20 11:57:48.546] [console] [trace] New
20/03/2020 17:27:48 [2020-03-20 11:57:48.547] [console] [trace] OidcFilter
20/03/2020 17:27:48 [2020-03-20 11:57:48.548] [console] [trace] Process
20/03/2020 17:27:48 [2020-03-20 11:57:48.548] [console] [debug] Call from @10.42.5.53 to @10.42.5.58
20/03/2020 17:27:48 [2020-03-20 11:57:48.549] [console] [trace] MatchesCallbackRequest: checking handler for ://microservice.url.com/appservice/oauth/callback?state=LeCNEqfwA6EUFGNGLt7JALx8jCWkPxjn7qCELbqkKrk&session_state=18f0e3b0-bee2-44a5-b049-6e349dbeda49&code=ddea1ea6-5616-416d-8291-c00bce6f2e9b.18f0e3b0-bee2-44a5-b049-6e349dbeda49.af7e7c31-fd4b-4a66-9856-25d1ac305d3f
20/03/2020 17:27:48 [2020-03-20 11:57:48.549] [console] [trace] RetrieveToken
20/03/2020 17:27:48 [2020-03-20 11:57:48.550] [console] [trace] Post
20/03/2020 17:27:48 [2020-03-20 11:57:48.618] [console] [info] Post: HTTP error encountered: stream truncated
20/03/2020 17:27:48 [2020-03-20 11:57:48.618] [console] [info] RetrieveToken: HTTP error encountered: IdP connection error
20/03/2020 17:27:48 [2020-03-20 11:57:48.618] [console] [trace] Request processing complete
20/03/2020 17:27:48 [2020-03-20 11:57:48.619] [console] [trace] Processing completion and deleting state

进一步检查代码,我发现这个错误是从这里触发的:Authservice oidc filter - Github

为了排除配置问题,我使用OpenID Debugger手动生成授权码,然后调用api换取api令牌。我能够成功检索它,这没有问题。但不知何故,authservice 失败了。

我这边会不会有什么问题?有没有人遇到过这个问题?任何帮助表示赞赏。让我知道是否需要更多详细信息。

【问题讨论】:

    标签: authentication openid openid-connect keycloak istio


    【解决方案1】:

    authservice 团队现已修复此问题。正如 authservice 的 Ryan 所说,这里的问题是:

    日志表明请求一直是成功的,直到 Authservice 尝试优雅关闭 TLS 连接,而另一端的服务器没有完全参与优雅关闭。

    这里的修复是忽略截断错误。该修复程序现已合并到 master 中,并将在下一个版本中提供。您可以自己构建 docker 映像以进行快速修复。有关问题和编译说明的更多详细信息,请访问this github issue

    【讨论】:

      猜你喜欢
      • 2017-09-28
      • 1970-01-01
      • 2014-10-12
      • 2021-08-20
      • 2018-09-30
      • 2014-02-14
      • 2015-03-30
      • 2015-06-12
      • 1970-01-01
      相关资源
      最近更新 更多