IdentityServer4 SPA 到 BFF 到 API 注销问题
IdentityServer4 SPA to BFF to API Logout Problem
我正在构建基于 IdentityServer4 的进程的原型,其中我有一个 Angular SPA,一个“前端后端”(BFF) ASP.NET 核心 API,以及后端 API 服务(也是 ASP.NET 核心)都与 https://demo.identityserver.io/ IdP 的衍生产品进行交互。
我的 BFF 和后端 API 服务基于在“https://github.com/leastprivilege/AspNetCoreSecuritySamples/tree/aspnetcore3/BFF”
找到的示例
一切都很顺利,直到我尝试创建用户选择从 IdP 注销页面注销的场景。 BFF 服务不会 'notice' 用户的令牌和会话一直 revoked/removed 直到令牌过期很久。
我怀疑我应该使用样本 https://github.com/IdentityServer/IdentityServer4/tree/main/samples/Clients/src/MvcHybridBackChannel 中的流程,其中 BFF 服务中的 cookie 事件处理程序实现 ValidatePrincipal(CookieValidatePrincipalContext context) 以显式调用 IdP 以验证用户的令牌根据每个请求。
第一个问题:这是完成此任务的正确模式吗?还是我把它变得不必要地复杂了?
第二个问题:通过什么方式询问IdP“Is this session still valid?” (这看起来应该很容易做到!)
提前致谢。
First question: is this the correct pattern to accomplish this? Or am I making this needlessly complex?
是的,它是正确的,当您直接从 IDP 注销时,您需要通知客户端应用程序用户已注销。如果你在 BFF 上使用 cookie,你需要为它做同样的事情。阅读更多 here
Second question: what is the method to ask the IdP "Is this session still valid?" (This seems like something that should be easy to do!)
Idp 不验证会话或 cookie,它验证令牌。 session/cookie 管理是客户端应用程序的责任。阅读更多 here
我正在构建基于 IdentityServer4 的进程的原型,其中我有一个 Angular SPA,一个“前端后端”(BFF) ASP.NET 核心 API,以及后端 API 服务(也是 ASP.NET 核心)都与 https://demo.identityserver.io/ IdP 的衍生产品进行交互。
我的 BFF 和后端 API 服务基于在“https://github.com/leastprivilege/AspNetCoreSecuritySamples/tree/aspnetcore3/BFF”
找到的示例一切都很顺利,直到我尝试创建用户选择从 IdP 注销页面注销的场景。 BFF 服务不会 'notice' 用户的令牌和会话一直 revoked/removed 直到令牌过期很久。
我怀疑我应该使用样本 https://github.com/IdentityServer/IdentityServer4/tree/main/samples/Clients/src/MvcHybridBackChannel 中的流程,其中 BFF 服务中的 cookie 事件处理程序实现 ValidatePrincipal(CookieValidatePrincipalContext context) 以显式调用 IdP 以验证用户的令牌根据每个请求。
第一个问题:这是完成此任务的正确模式吗?还是我把它变得不必要地复杂了?
第二个问题:通过什么方式询问IdP“Is this session still valid?” (这看起来应该很容易做到!)
提前致谢。
First question: is this the correct pattern to accomplish this? Or am I making this needlessly complex?
是的,它是正确的,当您直接从 IDP 注销时,您需要通知客户端应用程序用户已注销。如果你在 BFF 上使用 cookie,你需要为它做同样的事情。阅读更多 here
Second question: what is the method to ask the IdP "Is this session still valid?" (This seems like something that should be easy to do!)
Idp 不验证会话或 cookie,它验证令牌。 session/cookie 管理是客户端应用程序的责任。阅读更多 here