Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception: Correlation failed. AAD + Azure Front Door

I have a web application(ASP.NET Core MVC) which communicates with my REST API. Both of them are configured to use Azure Active Directory. Now I'm trying to configure Azure Front Door for the app, but I get the following error: enter image description here

or this one: enter image description here

I designed the front door for http-s redirection, configured the backend pool for website to use its own host name.

enter image description here

I've also configured the forwarded headers:

services.Configure<ForwardedHeadersOptions>(options =>
        {
            options.ForwardedHeaders =
                ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;

            options.KnownNetworks.Clear();
            options.KnownProxies.Clear();

            // Put your front door FQDN here and any other hosts that will send headers you want respected
            options.AllowedHosts = new List<string>() { "<my front door here>" };
        });

...

        app.UseForwardedHeaders();

However still getting the error. Any ideas?

Thanks.

like image 499
Dmitry Shevchuk Avatar asked Oct 24 '25 03:10

Dmitry Shevchuk


1 Answers

Blazor .NET 7 / December 2022 Update

I had the same issue FrontDoor + AzureAD + Front Door

On Program.cs

builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
    options.ForwardedHeaders =
        ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;

    options.KnownNetworks.Clear();
    options.KnownProxies.Clear();

    // Put your front door FQDN here and any other hosts that will send headers you want respected
    options.AllowedHosts = new List<string>() { "stage.x.y.com", "dev.x.y.com", "myapp.azurewebsites.net" };
});

...

builder.Services.Configure<CookiePolicyOptions>(options =>
{
    options.CheckConsentNeeded = context => true;//add if consent needed
    options.MinimumSameSitePolicy = SameSiteMode.None; // else try  SameSiteMode.Lax;

    options.Secure = CookieSecurePolicy.Always;
});

then Added app.UseForwardedHeaders(); and app.UseCookiePolicy(); in this order.

app.UseForwardedHeaders();
app.UseHttpsRedirection();
app.UseDefaultFiles();
app.UseStaticFiles();

app.UseCookiePolicy();
app.UseRouting();
like image 79
Thiago Loureiro Avatar answered Oct 26 '25 16:10

Thiago Loureiro