简体   繁体   English

带有OWIN的Azure B2C SSO

[英]Azure B2C SSO with OWIN

we are trying to achieve the following scenario involving two applications: 我们正在尝试实现以下涉及两个应用程序的方案:

  1. Both Web Applications APP1 and APP2 use Azure B2C Authentication Web应用程序APP1和APP2都使用Azure B2C身份验证
  2. User goes to APP1. 用户转到APP1。 Authentication Required, APP1 redirects to APP2 需要身份验证,APP1重定向到APP2
  3. APP2 authenticates against Azure B2C and then allows the user to select a setting which is stored in a cookie. APP2针对Azure B2C进行身份验证,然后允许用户选择存储在cookie中的设置。 Once done user is redirected back to APP1 完成后,用户将被重定向回APP1
  4. APP1 should now also be authenticated as it uses Azure B2C and SSO is configured in the policies. 由于APP1使用Azure B2C,并且在策略中配置了SSO,因此现在也应进行身份验证。 My issue is in step 4, APP1 won't recognize that the user already signed in against AB2C via APP2. 我的问题是在步骤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); 

原来是租户中缺少的配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM