aurelia 身份验证 OAuth2 响应状态值不同

aurelia-authentication OAuth2 response state value differs

我正在尝试使用 OIDC 提供程序 (IdentityServer4) 实施 aurelia 身份验证,似乎 运行 遇到了注销用户的问题。

简而言之,我无法使用 OIDC 配置部分 (https://aurelia-authentication.spoonx.org/oidc.html) 中提到的 authService.logout 功能成功注销用户。

在进一步调查后,我将其追踪到提供消息的注销功能中的承诺拒绝:"OAuth2 response state value differs"

if (logoutResponse.state !== stateValue) {
    return Promise.reject('OAuth2 response state value differs');
}

logoutReponse 似乎是罪魁祸首,因为它作为状态 属性 的对象被错误地命名 {/login?state: "qAIxYwKqLHYJtyar2PfdvaROWT1O56P7"}

我实际上可以将 if 语句更改为:

if (logoutResponse['/login?state'] !== stateValue) {
    return Promise.reject('OAuth2 response state value differs');
}

貌似没问题,但需要我们直接修改aurelia-authentication源。

任何人关于为什么 "state" 属性 作为相对路径而不只是 "state" 的任何想法?

因此,在花费更多时间后,我能够追踪问题并找到解决方案。

解决方案是将 aurelia-authentication authConfig postLogoutRedirectUri 值更改为根页面 (http://localhost:8080)。此外,我需要在我的 IdentityServer4 客户端定义中的 PostLogoutRedirectUris 下定义该 URI。

logoutResponse 然后通过一个名为 state 属性 的 属性 正确通过,它包含正确的值并允许成功重定向。