我已经从以下位置克隆了存储库redux-oidc-示例 https://github.com/maxmantz/redux-oidc-example它在大多数情况下都有效,但几个小时后它会出现以下错误:
操作负载:ErrorResponse:login_required
在新的 e (oidc-client.min.js:1)
在 t [as _processSigninParams] (oidc-client.min.js:1)
在 t [作为 validateSigninResponse] (oidc-client.min.js:1)
在 oidc-client.min.js:1
UserManager.js 看起来像这样:
const userManagerConfig = {
client_id: 'js.dev',
client_secret: 'secret',
redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/callback`,
response_type: 'id_token token',
scope: 'openid email profile role offline_access',
authority: 'http://localhost:8080',
silent_redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/silent_renew.html`,
automaticSilentRenew: true,
filterProtocolClaims: true,
loadUserInfo: true
};
和我的身份服务器配置:
{
"Enabled": true,
"ClientId": "js.dev",
"ClientName": "Javascript Client",
"ClientSecrets": [ { "Value": "K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols=" } ],
"AllowedGrantTypes": [ "implicit", "authorization_code" ],
"AllowedScopes": [ "openid", "email", "profile", "role", "offline_access" ],
"AllowOfflineAccess": true,
"AllowAccessTokensViaBrowser":true,
"RedirectUris": [
"http://localhost:8081/callback",
"http://localhost:8081/silent_renew.html"
],
"PostLogoutRedirectUris": [
"http://localhost:8081"
],
"AccessTokenLifetime": 900,
"RequireConsent": false
}
我注意到在错误发生之前,最后一个有效响应有一个 cookie 响应(idsrv.session),其值为空,到期日期设置为上一年:
我相信这是问题的根本原因,我在相关的 Github 存储库上搜索了它并尝试将 Cookie.SameSite 添加到 none 但没有帮助:
services.AddAuthentication()
.AddSaml(Configuration,externalProviders.UseSaml)
.AddCookie(options => {
options.SlidingExpiration = true;
options.ExpireTimeSpan = TimeSpan.FromDays(30);
options.Cookie.SameSite = SameSiteMode.None;
});
任何想法!