C# Azure B2C SSO与OWIN

C# Azure B2C SSO与OWIN,c#,single-sign-on,owin,azure-ad-b2c,openid-connect,C#,Single Sign On,Owin,Azure Ad B2c,Openid Connect,我们正在尝试实现以下涉及两个应用程序的场景: Web应用程序APP1和APP2都使用Azure B2C身份验证 用户转到APP1。需要身份验证,APP1重定向到APP2 APP2针对Azure B2C进行身份验证,然后允许用户选择存储在cookie中的设置。完成后,用户将重定向回APP1 APP1现在也应该进行身份验证,因为它使用Azure B2C,并且在策略中配置了SSO。 我的问题是在步骤4中,APP1无法识别用户已经通过APP2针对AB2C登录 var cookieAuth

我们正在尝试实现以下涉及两个应用程序的场景:

  • Web应用程序APP1和APP2都使用Azure B2C身份验证
  • 用户转到APP1。需要身份验证,APP1重定向到APP2
  • APP2针对Azure B2C进行身份验证,然后允许用户选择存储在cookie中的设置。完成后,用户将重定向回APP1
  • APP1现在也应该进行身份验证,因为它使用Azure B2C,并且在策略中配置了SSO。 我的问题是在步骤4中,APP1无法识别用户已经通过APP2针对AB2C登录

            var cookieAuthenticationOptions = new CookieAuthenticationOptions
        {
            CookieDomain = ".app.localhost",
            CookieName = "IAMAuthentication",
            ExpireTimeSpan = TimeSpan.FromMinutes(30),
            SlidingExpiration = true,
            CookieSecure = CookieSecureOption.SameAsRequest,
            LoginPath = new PathString("/login"),
            LogoutPath = new PathString("/logout"),
            Provider = new CookieAuthenticationProvider
            {
                OnApplyRedirect = ApplyCookieRedirect
            }
        };
    
        var openIdAuthOptions = new OpenIdConnectAuthenticationOptions
        {
            RedirectUri = RedirectUri,
            ClientId = ClientId,
            Authority = string.Format(AadInstance, ApiTenant, SignInPolicy),
            TokenValidationParameters = new TokenValidationParameters { NameClaimType = "name", SaveSigninToken = true },
            PostLogoutRedirectUri = RedirectUri
        };
    
        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
        app.UseCookieAuthentication(cookieAuthenticationOptions);
    
        app.UseOpenIdConnectAuthentication(openIdAuthOptions);
    
        app.UseStageMarker(PipelineStage.Authenticate);
    

  • 租户中缺少配置。

    租户中缺少配置。

    是否可以将App1和App2作为子域托管。App2中的身份验证cookie可能在App1上不可用。您可能还需要App1和App2的共享机器密钥,以便它们可以共享auth cookie。您好,这是一个有趣的问题,因为这在某些应用中发生,但不是在所有应用中都发生。OWIN启动类位于共享库中。问题是,在某些情况下,由于某些原因,APP2不会由中间件设置其context.Current.User。是否可以将App1和APP2作为子域托管。App2中的身份验证cookie可能在App1上不可用。您可能还需要App1和App2的共享机器密钥,以便它们可以共享auth cookie。您好,这是一个有趣的问题,因为这在某些应用中发生,但不是在所有应用中都发生。OWIN启动类位于共享库中。问题是,在某些情况下,由于某些原因,APP2不会由中间件设置context.Current.User。