Hello,
I am currently working on integration existing app with Azure ADB2C. Previously we were using form authentication. Now we want both form and ADB2C authentication.
I was able to implement ADB2C. But to make it work I had to change Authentication type from "form" to "none".
Due to which existing form authentication is not working, and even after successful login to system, app is redirecting to login page.
Also ADB2C is redirecting to login page even after successful login.
Now I am confused and need help to make both authentication work.
I am giving my startup.cs Configuration function here.
My requirement is both form and ADB2C authentication should work together.
Thank you!
public void Configuration(IAppBuilder app)
{
OAuthAuthorizationServerOptions authServerOptions = new OAuthAuthorizationServerOptions()
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/Token"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(240),
Provider = new AuthorizationServerProvider(),
RefreshTokenProvider = new RefreshTokenProvider()
};
app.UseOAuthAuthorizationServer(authServerOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
var corsOptions = new Microsoft.Owin.Cors.CorsOptions()
{
PolicyProvider = new Microsoft.Owin.Cors.CorsPolicyProvider
{
PolicyResolver = ctx =>
{
var policy = new CorsPolicy();
policy.AllowAnyHeader = true;
return Task.FromResult(policy);
}
}
};
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
// Generate the metadata address using the tenant and policy information
MetadataAddress = string.Format(Globals.WellKnownMetadata, Globals.Tenant, Globals.DefaultPolicy),
// These are standard OpenID Connect parameters, with values pulled from web.config
ClientId = Globals.ClientId,
RedirectUri = Globals.RedirectUri,
PostLogoutRedirectUri = Globals.RedirectUri,
// Specify the callbacks for each type of notifications
Notifications = new OpenIdConnectAuthenticationNotifications
{
RedirectToIdentityProvider = OnRedirectToIdentityProvider,
AuthorizationCodeReceived = OnAuthorizationCodeReceived,
AuthenticationFailed = OnAuthenticationFailed,
},
// Specify the scope by appending all of the scopes requested into one string (separated by a blank space)
Scope = $"openid profile offline_access {Globals.ReadTasksScope} {Globals.WriteTasksScope}",
// ASP.NET web host compatible cookie manager
CookieManager = new SystemWebCookieManager(),
UsePkce = false,
RequireHttpsMetadata = false,
}
);
app.UseStageMarker(PipelineStage.Authenticate);
app.UseCors(corsOptions);
IdentityModelEventSource.ShowPII = true;
RegisterSignalR(app);
GlobalConfiguration.Configure(WebApiConfig.Register);
GlobalConfiguration.Configuration.EnsureInitialized();
}