IdentityServer4 结束会话重定向到 account/logout 给出 404

IdentityServer4 endsession redirecting to account/logout giving 404

我在 Azure 中的 https url 上有 IdentityServer4 运行,我正在使用 Angular CLI 项目和 the angular-oauth2-oidc library 来处理隐式流。我正在尝试设置单点退出,但它无法正常工作。

我正在调用 logOut on the OAuthService,它已自动配置(通过发现文档)以在身份验证服务器上使用注销 url,即 https://my-id4-server.example.com/connect/endsession 的查询字符串参数包含一个 token_hint 和一个 postLogoutUri.

出于某种原因,实际行为 是 IdentityServer4 将浏览器重定向 (302) url https://my-id4-server.example.com/account/logout?logoutid=...,浏览器为此得到 404。此外,如果我在单独的选项卡中打开 IdentityServer 页面,我可以看到我的会话仍然有效。

预期行为 是我的会话结束,我被重定向回我的 SPA。

在 ID4Server 端我配置了:

此外,我可以在 .well-known 配置端点中看到正确配置的 endsession 端点。

在 SPA 方面,我配置了 issuerredirectUriclientIdscope。使用重定向返回登录工作正常。


底线:如果 endsession 端点重定向到 account/logout 而反过来给出 404,那有什么问题?

我猜 account/logout 是此流程的默认重定向,您需要在 IDS4 设置中将其更改为实际注销 URL 或简单地实现该端点。

根据设计,IDS4 在命中结束会话端点后将控制权交给您。您将获得一个 logoutid 参数,然后您可以将其与 IIdentityServerInteractionService 结合使用以获取有关结束会话请求的信息并采取必要的操作 - 例如提示确认,加载前端通道注销iframe,处理注销外部IDP等

问题是在 IdentityServer 端缺少 Logout(...) 的控制器操作。如果你没有这些,但其他所有东西 都在 那里,那么你就会得到所说的行为。