Identity Server 4 无提示续订错误响应:login_required

2024-06-10

我已经从以下位置克隆了存储库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;
                });

任何想法!


这可能是由于您的 IDP 会话过期 - 如果您致电authorize端点与prompt=none但它无法满足该请求,因为不存在有效会话(即身份验证 cookie 不存在或已过期),然后它将返回error=login_required.

如果发生这种情况,那么正确的做法是进行交互(即prompt=login) 在顶级浏览器窗口中登录请求。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Identity Server 4 无提示续订错误响应:login_required 的相关文章

随机推荐