From bdaa935b69f6b43e4656e1b16e95c595e0f5778a Mon Sep 17 00:00:00 2001 From: Kurt Brendon Date: Thu, 11 Feb 2021 15:07:29 -0800 Subject: [PATCH 1/5] Added proxy support --- src/customer-key-store/Startup.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/customer-key-store/Startup.cs b/src/customer-key-store/Startup.cs index a6eceb8..e4eac68 100644 --- a/src/customer-key-store/Startup.cs +++ b/src/customer-key-store/Startup.cs @@ -65,11 +65,10 @@ public void ConfigureServices(IServiceCollection services) options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.Strict; }); - - #if USE_TEST_KEYS - #error !!!!!!!!!!!!!!!!!!!!!! Use of test keys is only supported for testing, DO NOT USE FOR PRODUCTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!! + //#if USE_TEST_KEYS + //#error !!!!!!!!!!!!!!!!!!!!!! Use of test keys is only supported for testing, DO NOT USE FOR PRODUCTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!! services.AddSingleton(); - #endif + //#endif services.AddTransient(); services.AddMvc(options => options.EnableEndpointRouting = false); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); @@ -86,6 +85,22 @@ public void ConfigureServices(IServiceCollection services) options.Audience = Configuration["JwtAudience"]; options.TokenValidationParameters.ValidateIssuerSigningKey = true; options.Challenge = "Bearer resource=\"" + Configuration["JwtAudience"] + "\", authorization=\"" + Configuration["JwtAuthorization"] + "\", realm=\"" + Configuration["JwtAudience"] + "\""; + + var proxyConfig = Configuration.GetSection("Proxy"); + if(proxyConfig != null && proxyConfig.Exists()) + { + options.BackchannelHttpHandler = new System.Net.Http.HttpClientHandler + { + UseProxy = true, + Proxy = new System.Net.WebProxy + { + Address = new System.Uri(proxyConfig["address"]), + BypassProxyOnLocal = true, + UseDefaultCredentials = true, + }, + }; + } + options.Events = new JwtBearerEvents { OnChallenge = context => From 3899f19a32b69fd13cdb25cc059ce908b46ee5ec Mon Sep 17 00:00:00 2001 From: Kurt Brendon Date: Fri, 5 Mar 2021 06:48:27 -0800 Subject: [PATCH 2/5] Mistaken change removal --- src/customer-key-store/Startup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/customer-key-store/Startup.cs b/src/customer-key-store/Startup.cs index e4eac68..34bde2d 100644 --- a/src/customer-key-store/Startup.cs +++ b/src/customer-key-store/Startup.cs @@ -65,10 +65,10 @@ public void ConfigureServices(IServiceCollection services) options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.Strict; }); - //#if USE_TEST_KEYS - //#error !!!!!!!!!!!!!!!!!!!!!! Use of test keys is only supported for testing, DO NOT USE FOR PRODUCTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!! + #if USE_TEST_KEYS + #error !!!!!!!!!!!!!!!!!!!!!! Use of test keys is only supported for testing, DO NOT USE FOR PRODUCTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!! services.AddSingleton(); - //#endif + #endif services.AddTransient(); services.AddMvc(options => options.EnableEndpointRouting = false); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); From c7b325eebf481914f942f3033b5c651599ae1244 Mon Sep 17 00:00:00 2001 From: Kurt Brendon Date: Fri, 5 Mar 2021 06:49:01 -0800 Subject: [PATCH 3/5] Added missing line --- src/customer-key-store/Startup.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/customer-key-store/Startup.cs b/src/customer-key-store/Startup.cs index 34bde2d..6da3d70 100644 --- a/src/customer-key-store/Startup.cs +++ b/src/customer-key-store/Startup.cs @@ -69,6 +69,7 @@ public void ConfigureServices(IServiceCollection services) #error !!!!!!!!!!!!!!!!!!!!!! Use of test keys is only supported for testing, DO NOT USE FOR PRODUCTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!! services.AddSingleton(); #endif + services.AddTransient(); services.AddMvc(options => options.EnableEndpointRouting = false); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); From 2d7edb2466b42872538cc116757561b37cbb4d9a Mon Sep 17 00:00:00 2001 From: Kurt Brendon Date: Fri, 5 Mar 2021 06:50:11 -0800 Subject: [PATCH 4/5] More line fixes --- src/customer-key-store/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/customer-key-store/Startup.cs b/src/customer-key-store/Startup.cs index 6da3d70..7ecee2c 100644 --- a/src/customer-key-store/Startup.cs +++ b/src/customer-key-store/Startup.cs @@ -65,11 +65,11 @@ public void ConfigureServices(IServiceCollection services) options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.Strict; }); + #if USE_TEST_KEYS #error !!!!!!!!!!!!!!!!!!!!!! Use of test keys is only supported for testing, DO NOT USE FOR PRODUCTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!! services.AddSingleton(); #endif - services.AddTransient(); services.AddMvc(options => options.EnableEndpointRouting = false); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); From fa2b462391db8908e00e7e0ec150de6a323f3805 Mon Sep 17 00:00:00 2001 From: Kurt Brendon Date: Fri, 5 Mar 2021 06:50:49 -0800 Subject: [PATCH 5/5] Whitespace removal --- src/customer-key-store/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/customer-key-store/Startup.cs b/src/customer-key-store/Startup.cs index 7ecee2c..2ce368c 100644 --- a/src/customer-key-store/Startup.cs +++ b/src/customer-key-store/Startup.cs @@ -65,7 +65,7 @@ public void ConfigureServices(IServiceCollection services) options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.Strict; }); - + #if USE_TEST_KEYS #error !!!!!!!!!!!!!!!!!!!!!! Use of test keys is only supported for testing, DO NOT USE FOR PRODUCTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!! services.AddSingleton();