我已经从redux-oidc-example克隆了仓库,它在大多数情况下都起作用,但是几个小时后,它给出了以下错误:
操作有效负载:ErrorResponse: 在t的
新e(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添加为无,但没有帮助:
services.AddAuthentication()
.AddSaml(Configuration,externalProviders.UseSaml)
.AddCookie(options => {
options.SlidingExpiration = true;
options.ExpireTimeSpan = TimeSpan.FromDays(30);
options.Cookie.SameSite = SameSiteMode.None;
});
任何想法!
搜索Identity Server 4存储库后,对代码进行了以下更改:
services.AddIdentityServer(options=>
{
options.Authentication.CookieLifetime = TimeSpan.FromDays(30);
options.Authentication.CookieSlidingExpiration = true;
})
.AddProfileService<ProfileService>()
.AddSigningCertificate(Configuration)
.AddInMemoryClients(Configuration.GetSection("IdentityServer:Clients"))
.AddInMemoryIdentityResources(Resources.GetIdentityResources());
之后它开始工作,但是关闭浏览器或重新打开新标签后,您必须再次登录,我猜这是由于sessionStorage所致。
我有同样的问题。您是否最终解决了您的问题?
是的,通过上述更改,它开始为我工作。
您能否报告整个ConfigureServices方法?如果您愿意,可以评论我自己的问题stackoverflow.com/questions/63901667/…
当然,我没有足够的空间进入此处,我将在您的问题上发表。