带有OKTA的OpenIdConnect配置

问题描述 投票:0回答:1

我有一个使用OpenIdConnectAuthenntication的Web应用程序。有用于登录和注销页面的地图。下面显示的示例用于登录。

        app.Map("/login.aspx", map =>
        {
            map.Run(ctx =>
            {
                if (ctx.Authentication.User == null || !ctx.Authentication.User.Identity.IsAuthenticated)
                {
                    // trigger authentication
                    ctx.Response.StatusCode = 401;
                }
                else
                {
                    ctx.Response.Redirect("/");
                }

                return Task.FromResult(0);
            });
        });

我试图找到一种完全退出openidconnect选项并在状态代码= 401行时将用户重定向到全新的Web应用程序的方法。

这里的目的是我有两个应用程序A和B。两者都使用OKTA身份验证。出于某种原因,我需要将直接进入应用程序A的用户重定向到B,并让他们在那登录。一旦从B进行身份验证,它们将被路由到A。我需要B成为应用程序A的入口门。

asp.net-mvc okta episerver
1个回答
0
投票

[OpenID Owin实现中有一个AuthenticationFailed事件(称为通知)

示例

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
      // config...
      ClientId = //...,
      ClientSecret = // ...,
      // etc

      // events
      Notifications = new OpenIdConnectAuthenticationNotifications
      {
      // AuthenticationFailed
            AuthenticationFailed = context =>
            {
                  context.HandleResponse();

                  // Handle redirect

                  //context.Response.Write(context.Exception.Message);
                  //_logger.Log(context.Exception.Message);
                  return Task.FromResult(0);
            },
            // ...
      }
}

更完整的示例可以在这里找到https://github.com/EricHerlitz/Identityserver4-Episerver-Demo/blob/master/IdEpi/IdEpi.WebEpiserver/Business/Owin/Startup.cs

© www.soinside.com 2019 - 2024. All rights reserved.