asp.net-coreblazorwindows-authenticationdev-tunnels

Windows authentication in DevTunnels


I have a blazor server application with windows authentication.
Server configuration:

builder.Services.AddAuthentication(HttpSysDefaults.AuthenticationScheme);
builder.WebHost.UseHttpSys(options =>
{
    options.Authentication.Schemes =
        AuthenticationSchemes.Negotiate |
        AuthenticationSchemes.NTLM;
    options.Authentication.AllowAnonymous = false;
});

I run application with this launch profile:

    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": false,
      "applicationUrl": "http://localhost:5105",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development",
      }
    },

When I run app and access it from localhost:5105 it works fine. When entering from incognito mode, I provide my windows credentials and gain access. However, hen I try to enter application from dev tunnel url (on my machine), sign in prompt shows up, but logging with my windows credentials does not work. I tried different variations: username alone, username with full domain, username with ".". Each time app prompts for credentials again. Any idea what might be the reason?


Solution

  • After investigation, we can't use Windows Authentication when penetrating the intranet. I have verified it by using DevTunnel and Ngrok.

    When using devtunnel, we will get a url. After parsing it through nslookup, we will see the following information about ip 168.63.129.16.

    enter image description here

    To sum it up in one sentence, after using the URL mapped within the intranet, the machine you want to enable windows authentication on is not a local physical machine, but a gateway machine, so it is not feasible.