Skip to main content

OpenIdConnect through a proxy

1 min read

Having set up OpenIdConnect in a dotnet core project using services.AddOpenIdConnect the log in proces is kiked of in some method of the application via the call to the base controller Challenge(OpenIdConnectDefaults.AuthenticationScheme)

            if (!HttpContext.User.Identity.IsAuthenticated)
                return Challenge(OpenIdConnectDefaults.AuthenticationScheme);

Works fine in development. Fails in production because prod goes through a proxy.
How do you set that proxy?

Use the followng:

            .AddOpenIdConnect(options =>
                if (environment != "DEV")             
  {                    var proxy = new WebProxy(proxyUrl); 
                  options.BackchannelHttpHandler = new HttpClientHandler() 
                  {                        Proxy = proxy                   
options ......

Not documented ANYWHERE!