From ac3911b112d021d7a50d004b3e36782527bbd4d3 Mon Sep 17 00:00:00 2001 From: Laurence Bargery <48315337+lbargery@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:42:56 +0100 Subject: [PATCH 1/5] Update to net core 8 --- NHS-Login-Dotnet-Core-Sample.csproj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NHS-Login-Dotnet-Core-Sample.csproj b/NHS-Login-Dotnet-Core-Sample.csproj index 69eec41..9fa1186 100644 --- a/NHS-Login-Dotnet-Core-Sample.csproj +++ b/NHS-Login-Dotnet-Core-Sample.csproj @@ -1,8 +1,7 @@ - + - netcoreapp2.2 - InProcess + net8.0 @@ -10,7 +9,9 @@ + + From ceca3a7838505d866dd2a48d29f186e680ea4261 Mon Sep 17 00:00:00 2001 From: Laurence Bargery <48315337+lbargery@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:44:13 +0100 Subject: [PATCH 2/5] Update Startup.cs --- Startup.cs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Startup.cs b/Startup.cs index 97705af..8cf16de 100644 --- a/Startup.cs +++ b/Startup.cs @@ -1,9 +1,4 @@ -using System.Collections.Generic; -using System.IO; -using System.Security.Cryptography; -using System.Text; using System.Threading.Tasks; -using IdentityModel; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Builder; @@ -12,11 +7,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Org.BouncyCastle.Crypto.Parameters; -using Org.BouncyCastle.OpenSsl; -using Org.BouncyCastle.Security; -using Base64Url = Jose.Base64Url; namespace NHS.Login.Dotnet.Core.Sample { @@ -47,7 +39,7 @@ public void ConfigureServices(IServiceCollection services) .AddCookie() .AddOpenIdConnect(options => { - options.ClientId = "YOUR-CLIENT-ID"; + options.ClientId = "CLIENTID"; options.Authority = "https://auth.sandpit.signin.nhs.uk/"; options.ResponseType = "code"; options.ResponseMode = "form_post"; @@ -78,14 +70,12 @@ public void ConfigureServices(IServiceCollection services) } }; }); - - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { @@ -99,17 +89,17 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) } app.UseAuthentication(); + + app.UseRouting(); + + app.UseAuthorization(); + app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); - app.UseMvc(routes => - { - routes.MapRoute( - name: "default", - template: "{controller=Home}/{action=Index}/{id?}"); - }); + app.UseEndpoints(e => e.MapDefaultControllerRoute()); } } } From a15babc065c2af9c7a409bbb9b74fcca2f01bb38 Mon Sep 17 00:00:00 2001 From: Laurence Bargery <48315337+lbargery@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:46:42 +0100 Subject: [PATCH 3/5] Update Startup.cs --- Startup.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Startup.cs b/Startup.cs index 8cf16de..2312425 100644 --- a/Startup.cs +++ b/Startup.cs @@ -31,6 +31,7 @@ public void ConfigureServices(IServiceCollection services) options.MinimumSameSitePolicy = SameSiteMode.None; }); + services.AddMvc(); services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; @@ -39,7 +40,7 @@ public void ConfigureServices(IServiceCollection services) .AddCookie() .AddOpenIdConnect(options => { - options.ClientId = "CLIENTID"; + options.ClientId = "YOUR-CLIENT-ID"; options.Authority = "https://auth.sandpit.signin.nhs.uk/"; options.ResponseType = "code"; options.ResponseMode = "form_post"; From c54504b48c88a6a479a5c5ad356f23e0d7829d33 Mon Sep 17 00:00:00 2001 From: Laurence Bargery <48315337+lbargery@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:55:51 +0100 Subject: [PATCH 4/5] Update Startup.cs --- Startup.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Startup.cs b/Startup.cs index 2312425..ba5f5a6 100644 --- a/Startup.cs +++ b/Startup.cs @@ -32,6 +32,8 @@ public void ConfigureServices(IServiceCollection services) }); services.AddMvc(); + services.AddControllersWithViews().AddRazorRuntimeCompilation(); + services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; @@ -100,7 +102,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseStaticFiles(); app.UseCookiePolicy(); - app.UseEndpoints(e => e.MapDefaultControllerRoute()); + app.UseEndpoints(e => + { + e.MapDefaultControllerRoute(); + e.MapRazorPages(); + }); } } } From c589f69bb9eea02a53a7b61a0946bf20332b5beb Mon Sep 17 00:00:00 2001 From: Laurence Bargery <48315337+lbargery@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:56:08 +0100 Subject: [PATCH 5/5] Update NHS-Login-Dotnet-Core-Sample.csproj --- NHS-Login-Dotnet-Core-Sample.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/NHS-Login-Dotnet-Core-Sample.csproj b/NHS-Login-Dotnet-Core-Sample.csproj index 9fa1186..505cff5 100644 --- a/NHS-Login-Dotnet-Core-Sample.csproj +++ b/NHS-Login-Dotnet-Core-Sample.csproj @@ -10,6 +10,7 @@ +