John Sharland
John Sharland

Reputation: 53

IdentityServer4 configure OpenId connect provider to use proxy server

I am using IdentityServer4 to provide authentication and token generation for my new services and I have it all working successfully. I have configured my server to use Azure AD as an oidc provider which has been working ok in my staging environment because the ip address for Azure AD is configured in the firewall. Today that ip address appears to have changed because my code is unable to make a call to Azure AD to get the openid well known configuration (https://login.microsoftonline.com/[mytenantid]/.well-known/openid-configuration).

I configure the provider using the following code:

services.AddAuthentication()
            .AddOpenIdConnect("oidc", "AzureAD", options =>
            {
                options.ClientId = Configuration["adclientid"];
                options.ClientSecret = Configuration["adsecret"];
                options.Authority = $"{Configuration["addomain"]}{Configuration["adtenantid"]}";
                options.UseTokenLifetime = true;
                options.CallbackPath = "/signin-oidc";
                options.RequireHttpsMetadata = false;
            })
            .AddCookie();

Our company does have a proxy server available which will let my code make the calls and not be affected whenever the ip address changes. How can I amend my code to make it use the proxy?

Upvotes: 0

Views: 1043

Answers (1)

user2798378
user2798378

Reputation: 41

Try to add a BackchannelHttpHandler:

.AddOpenIdConnect("aad", "Azure AD", options =>
                {
                    options.BackchannelHttpHandler = new HttpClientHandler { Proxy = Proxy};
                    ....

Upvotes: 4

Related Questions