【问题标题】:ASP.NET MVC client connect ids4 SSo [Authorize] 302 redirect alwaysASP.NET MVC 客户端连接 ids4 SSo [授权] 302 总是重定向
【发布时间】:2021-08-03 15:20:40
【问题描述】:

客户端代码

public void ConfigureServices(IServiceCollection services)
{
    services.AddControllersWithViews();

    IdentityModelEventSource.ShowPII = true;

    JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

    services.AddAuthentication(options =>
            {
                options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
            })
               .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
               {
                   options.AccessDeniedPath = "/Authorization/AccessDenied";
               })
               .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options =>
               {
                   options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                   options.Authority = "https://jpprojectsso.inthink.top:5000"; //
                   options.RequireHttpsMetadata = false;

                   options.ClientId = "TestClient";
                   options.ClientSecret = "Client Secrets";
                   options.SaveTokens = true;
                   options.ResponseType = "code id_token";
                   options.GetClaimsFromUserInfoEndpoint = true;

                   options.Scope.Clear();
                   options.Scope.Add(OidcConstants.StandardScopes.OpenId);
                   options.Scope.Add(OidcConstants.StandardScopes.Profile);

               });
}
    

控制器如下所示:

[Authorize]
public IActionResult Privacy()
{
    var user = User.Identity.Name;
    return View();
}

ids4 连接客户端成功。但是客户端总是 302 重定向到 sso 并且 sso 成功重定向到客户端...在循环中。

我的 sso 使用 Jp 项目 ids4。我该如何解决这个问题?

谢谢,

【问题讨论】:

    标签: single-sign-on identityserver4 openid-connect


    【解决方案1】:

    我发现了错误... 在无效的配置函数中。

    app.UseAuthorization() 应该在 app.UseAuthentication() 之后执行

    然后就可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-05
      • 2015-06-09
      • 2020-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-01
      相关资源
      最近更新 更多