From 43ca0ae98057764e876cd931e0a5a7a4a1948d6d Mon Sep 17 00:00:00 2001 From: Maarten Balliauw Date: Fri, 12 Dec 2025 09:18:34 +0100 Subject: [PATCH 01/11] Update templates to .NET 10 and latest IdentityServer 7.4.x --- .../IdentityServerTemplate.csproj | 14 ++++++------ .../IdentityServer/Pages/Admin/Index.cshtml | 8 +++---- .../Pages/Admin/Index.cshtml.cs | 22 ++++++++++++------- .../Pages/Diagnostics/ViewModel.cs | 4 ++-- .../IdentityServerAspNetIdentity.csproj | 19 +++++++++------- .../Pages/Diagnostics/ViewModel.cs | 4 ++-- .../IdentityServerEmpty.csproj | 6 ++--- .../IdentityServerEntityFramework.csproj | 16 ++++++++------ .../IdentityServerInMem.csproj | 6 ++--- .../src/WebApp/TemplateWebApp.csproj | 8 +++---- 10 files changed, 58 insertions(+), 49 deletions(-) diff --git a/identity-server/templates/src/IdentityServer/IdentityServerTemplate.csproj b/identity-server/templates/src/IdentityServer/IdentityServerTemplate.csproj index fe10932d6..81ea4483c 100644 --- a/identity-server/templates/src/IdentityServer/IdentityServerTemplate.csproj +++ b/identity-server/templates/src/IdentityServer/IdentityServerTemplate.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable IdentityServerTemplate @@ -12,13 +12,13 @@ - - - + + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/identity-server/templates/src/IdentityServer/Pages/Admin/Index.cshtml b/identity-server/templates/src/IdentityServer/Pages/Admin/Index.cshtml index 8f23eddc6..84fcfc3b8 100644 --- a/identity-server/templates/src/IdentityServer/Pages/Admin/Index.cshtml +++ b/identity-server/templates/src/IdentityServer/Pages/Admin/Index.cshtml @@ -12,11 +12,11 @@ Admin Dashboard - Get a high-level overview of your Duende IdentityServer instance. - Click here to access the Discovery Document. + Get a high-level overview of your Duende IdentityServer instance.
+ Click here to access the Discovery Document.
+ Download diagnostics data
-

System Information

@@ -55,10 +55,8 @@
-

License Usage

-
diff --git a/identity-server/templates/src/IdentityServer/Pages/Admin/Index.cshtml.cs b/identity-server/templates/src/IdentityServer/Pages/Admin/Index.cshtml.cs index a6cc7e224..e062e264e 100644 --- a/identity-server/templates/src/IdentityServer/Pages/Admin/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServer/Pages/Admin/Index.cshtml.cs @@ -1,17 +1,23 @@ -using System.Reflection; -using Duende.IdentityServer; +using Duende.IdentityServer.Services; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace IdentityServerTemplate.Pages.Admin; [Authorize(Config.Policies.Admin)] -public class Index(IdentityServerLicense? license = null) : PageModel +public class Index(DiagnosticDataService? diagnosticDataService = null) : PageModel { - public string Version => typeof(Duende.IdentityServer.Hosting.IdentityServerMiddleware).Assembly - .GetCustomAttribute() - ?.InformationalVersion.Split('+').First() - ?? "unavailable"; + public async Task OnGetDiagnostics() + { + if (diagnosticDataService == null) + { + return NotFound(); + } - public IdentityServerLicense? License { get; } = license; + var diagnosticsJson = await diagnosticDataService.GetJsonStringAsync(); + + Response.Headers.ContentDisposition = "attachment; filename=diagnostics.json"; + return Content(diagnosticsJson, "application/json"); + } } diff --git a/identity-server/templates/src/IdentityServer/Pages/Diagnostics/ViewModel.cs b/identity-server/templates/src/IdentityServer/Pages/Diagnostics/ViewModel.cs index 4ac5bb95d..d683f62ed 100644 --- a/identity-server/templates/src/IdentityServer/Pages/Diagnostics/ViewModel.cs +++ b/identity-server/templates/src/IdentityServer/Pages/Diagnostics/ViewModel.cs @@ -1,6 +1,6 @@ +using System.Buffers.Text; using System.Text; using System.Text.Json; -using Duende.IdentityModel; using Microsoft.AspNetCore.Authentication; namespace IdentityServerTemplate.Pages.Diagnostics; @@ -15,7 +15,7 @@ public class ViewModel { if (encoded != null) { - var bytes = Base64Url.Decode(encoded); + var bytes = Base64Url.DecodeFromChars(encoded); var value = Encoding.UTF8.GetString(bytes); Clients = JsonSerializer.Deserialize(value) ?? Enumerable.Empty(); return; diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/IdentityServerAspNetIdentity.csproj b/identity-server/templates/src/IdentityServerAspNetIdentity/IdentityServerAspNetIdentity.csproj index fef5e2e0b..6d69b515b 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/IdentityServerAspNetIdentity.csproj +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/IdentityServerAspNetIdentity.csproj @@ -1,19 +1,22 @@  - net8.0 + net10.0 enable enable - - + + - - - - - + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Diagnostics/ViewModel.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Diagnostics/ViewModel.cs index 5dcffe552..d565497d3 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Diagnostics/ViewModel.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Diagnostics/ViewModel.cs @@ -1,6 +1,6 @@ +using System.Buffers.Text; using System.Text; using System.Text.Json; -using Duende.IdentityModel; using Microsoft.AspNetCore.Authentication; namespace IdentityServerHost.Pages.Diagnostics; @@ -15,7 +15,7 @@ public class ViewModel { if (encoded != null) { - var bytes = Base64Url.Decode(encoded); + var bytes = Base64Url.DecodeFromChars(encoded); var value = Encoding.UTF8.GetString(bytes); Clients = JsonSerializer.Deserialize(value) ?? Enumerable.Empty(); return; diff --git a/identity-server/templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj b/identity-server/templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj index 2920d4a7d..3263c222c 100644 --- a/identity-server/templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj +++ b/identity-server/templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj @@ -1,14 +1,14 @@  - net8.0 + net10.0 enable enable - + - + diff --git a/identity-server/templates/src/IdentityServerEntityFramework/IdentityServerEntityFramework.csproj b/identity-server/templates/src/IdentityServerEntityFramework/IdentityServerEntityFramework.csproj index 0c89293c3..b9cf91e6a 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/IdentityServerEntityFramework.csproj +++ b/identity-server/templates/src/IdentityServerEntityFramework/IdentityServerEntityFramework.csproj @@ -1,19 +1,21 @@  - net8.0 + net10.0 enable enable - - + + - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/identity-server/templates/src/IdentityServerInMem/IdentityServerInMem.csproj b/identity-server/templates/src/IdentityServerInMem/IdentityServerInMem.csproj index 65a2dcc39..774d4caca 100644 --- a/identity-server/templates/src/IdentityServerInMem/IdentityServerInMem.csproj +++ b/identity-server/templates/src/IdentityServerInMem/IdentityServerInMem.csproj @@ -1,14 +1,14 @@  - net8.0 + net10.0 enable enable - - + + diff --git a/identity-server/templates/src/WebApp/TemplateWebApp.csproj b/identity-server/templates/src/WebApp/TemplateWebApp.csproj index 231ca8b8b..365be4016 100644 --- a/identity-server/templates/src/WebApp/TemplateWebApp.csproj +++ b/identity-server/templates/src/WebApp/TemplateWebApp.csproj @@ -1,15 +1,15 @@ - net9.0 + net10.0 enable enable - - - + + + From 77869be0d23fba059f969aea58d908a4134214da Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:00:59 +0100 Subject: [PATCH 02/11] Use .NET Base64Url encoder --- .../Pages/Diagnostics/ViewModel.cs | 4 ++-- .../src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Diagnostics/ViewModel.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Diagnostics/ViewModel.cs index 5dcffe552..2b460a4d3 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Diagnostics/ViewModel.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Diagnostics/ViewModel.cs @@ -11,11 +11,11 @@ public class ViewModel { AuthenticateResult = result; - if (result?.Properties?.Items.TryGetValue("client_list", out var encoded) == true) + if (result.Properties?.Items.TryGetValue("client_list", out var encoded) == true) { if (encoded != null) { - var bytes = Base64Url.Decode(encoded); + var bytes = Base64Url.DecodeFromChars(encoded); var value = Encoding.UTF8.GetString(bytes); Clients = JsonSerializer.Deserialize(value) ?? Enumerable.Empty(); return; diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs index 5dcffe552..64f46488d 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs @@ -15,7 +15,7 @@ public class ViewModel { if (encoded != null) { - var bytes = Base64Url.Decode(encoded); + var bytes = Base64Url.DecodeFromChars(encoded); var value = Encoding.UTF8.GetString(bytes); Clients = JsonSerializer.Deserialize(value) ?? Enumerable.Empty(); return; From f4aa2fc900370f307b7af1394f969b50d32832a2 Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:19:47 +0100 Subject: [PATCH 03/11] IdentityServerEntityFramework: Set the root namespace to IdentityServerHost Adjust namespaces of all files accordingly. --- .../src/IdentityServerEntityFramework/Config.cs | 2 +- .../IdentityServerEntityFramework/HostingExtensions.cs | 4 ++-- .../IdentityServerEntityFramework.csproj | 1 + .../20240123193245_Configuration.Designer.cs | 9 ++++----- .../ConfigurationDb/20240123193245_Configuration.cs | 6 +++--- .../PersistedGrantDb/20240123193240_Grants.Designer.cs | 9 ++++----- .../Migrations/PersistedGrantDb/20240123193240_Grants.cs | 6 +++--- .../Pages/Account/Create/Index.cshtml | 4 ++-- .../Pages/Account/Create/Index.cshtml.cs | 2 +- .../Pages/Account/Create/InputModel.cs | 2 +- .../Pages/Account/Login/Index.cshtml | 4 ++-- .../Pages/Account/Login/Index.cshtml.cs | 2 +- .../Pages/Account/Login/InputModel.cs | 2 +- .../Pages/Account/Login/LoginOptions.cs | 2 +- .../Pages/Account/Login/ViewModel.cs | 2 +- .../Pages/Account/Logout/Index.cshtml | 4 ++-- .../Pages/Account/Logout/Index.cshtml.cs | 2 +- .../Pages/Account/Logout/LoggedOut.cshtml | 4 ++-- .../Pages/Account/Logout/LoggedOut.cshtml.cs | 2 +- .../Pages/Account/Logout/LoggedOutViewModel.cs | 2 +- .../Pages/Account/Logout/LogoutOptions.cs | 2 +- .../Pages/Diagnostics/ViewModel.cs | 3 ++- .../Pages/{Home => }/Error/Index.cshtml | 0 .../Pages/{Home => }/Error/Index.cshtml.cs | 0 .../Pages/{Home => }/Error/ViewModel.cs | 0 .../Pages/{ => Home}/Index.cshtml | 2 +- .../Pages/{ => Home}/Index.cshtml.cs | 2 +- .../src/IdentityServerEntityFramework/Pages/TestUsers.cs | 2 +- .../Pages/_ViewImports.cshtml | 3 +-- .../src/IdentityServerEntityFramework/Program.cs | 2 +- .../src/IdentityServerEntityFramework/SeedData.cs | 2 +- 31 files changed, 44 insertions(+), 45 deletions(-) rename identity-server/templates/src/IdentityServerEntityFramework/Pages/{Home => }/Error/Index.cshtml (100%) rename identity-server/templates/src/IdentityServerEntityFramework/Pages/{Home => }/Error/Index.cshtml.cs (100%) rename identity-server/templates/src/IdentityServerEntityFramework/Pages/{Home => }/Error/ViewModel.cs (100%) rename identity-server/templates/src/IdentityServerEntityFramework/Pages/{ => Home}/Index.cshtml (97%) rename identity-server/templates/src/IdentityServerEntityFramework/Pages/{ => Home}/Index.cshtml.cs (93%) diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Config.cs b/identity-server/templates/src/IdentityServerEntityFramework/Config.cs index 10ee1941e..731e829e0 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Config.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Config.cs @@ -1,6 +1,6 @@ using Duende.IdentityServer.Models; -namespace IdentityServerEntityFramework; +namespace IdentityServerHost; public static class Config { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/HostingExtensions.cs b/identity-server/templates/src/IdentityServerEntityFramework/HostingExtensions.cs index 99f86480a..01a6b72ae 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/HostingExtensions.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/HostingExtensions.cs @@ -1,6 +1,6 @@ using System.Globalization; using Duende.IdentityServer; -using IdentityServerHost; +using IdentityServerHost.Pages; using IdentityServerHost.Pages.Admin.ApiScopes; using IdentityServerHost.Pages.Admin.Clients; using IdentityServerHost.Pages.Admin.IdentityScopes; @@ -10,7 +10,7 @@ using Microsoft.IdentityModel.Tokens; using Serilog; using Serilog.Filters; -namespace IdentityServerEntityFramework; +namespace IdentityServerHost; internal static class HostingExtensions { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/IdentityServerEntityFramework.csproj b/identity-server/templates/src/IdentityServerEntityFramework/IdentityServerEntityFramework.csproj index b9cf91e6a..087f7c6e0 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/IdentityServerEntityFramework.csproj +++ b/identity-server/templates/src/IdentityServerEntityFramework/IdentityServerEntityFramework.csproj @@ -4,6 +4,7 @@ net10.0 enable enable + IdentityServerHost
diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Migrations/ConfigurationDb/20240123193245_Configuration.Designer.cs b/identity-server/templates/src/IdentityServerEntityFramework/Migrations/ConfigurationDb/20240123193245_Configuration.Designer.cs index 2c9f92bbc..c9d49a80f 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Migrations/ConfigurationDb/20240123193245_Configuration.Designer.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Migrations/ConfigurationDb/20240123193245_Configuration.Designer.cs @@ -1,14 +1,13 @@ // -using System; + +#nullable disable + using Duende.IdentityServer.EntityFramework.DbContexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -#nullable disable - -namespace IdentityServerEntityFramework.Migrations.ConfigurationDb +namespace IdentityServerHost.Migrations.ConfigurationDb { [DbContext(typeof(ConfigurationDbContext))] [Migration("20240123193245_Configuration")] diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Migrations/ConfigurationDb/20240123193245_Configuration.cs b/identity-server/templates/src/IdentityServerEntityFramework/Migrations/ConfigurationDb/20240123193245_Configuration.cs index cdf542b34..3cbcddc92 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Migrations/ConfigurationDb/20240123193245_Configuration.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Migrations/ConfigurationDb/20240123193245_Configuration.cs @@ -1,8 +1,8 @@ -using Microsoft.EntityFrameworkCore.Migrations; - #nullable disable -namespace IdentityServerEntityFramework.Migrations.ConfigurationDb; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace IdentityServerHost.Migrations.ConfigurationDb; /// public partial class Configuration : Migration diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Migrations/PersistedGrantDb/20240123193240_Grants.Designer.cs b/identity-server/templates/src/IdentityServerEntityFramework/Migrations/PersistedGrantDb/20240123193240_Grants.Designer.cs index 363080811..4bf5a3411 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Migrations/PersistedGrantDb/20240123193240_Grants.Designer.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Migrations/PersistedGrantDb/20240123193240_Grants.Designer.cs @@ -1,14 +1,13 @@ // -using System; + +#nullable disable + using Duende.IdentityServer.EntityFramework.DbContexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -#nullable disable - -namespace IdentityServerEntityFramework.Migrations.PersistedGrantDb +namespace IdentityServerHost.Migrations.PersistedGrantDb { [DbContext(typeof(PersistedGrantDbContext))] [Migration("20240123193240_Grants")] diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Migrations/PersistedGrantDb/20240123193240_Grants.cs b/identity-server/templates/src/IdentityServerEntityFramework/Migrations/PersistedGrantDb/20240123193240_Grants.cs index 93fa2f837..eb26bbe78 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Migrations/PersistedGrantDb/20240123193240_Grants.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Migrations/PersistedGrantDb/20240123193240_Grants.cs @@ -1,8 +1,8 @@ -using Microsoft.EntityFrameworkCore.Migrations; - #nullable disable -namespace IdentityServerEntityFramework.Migrations.PersistedGrantDb; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace IdentityServerHost.Migrations.PersistedGrantDb; /// public partial class Grants : Migration diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/Index.cshtml b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/Index.cshtml index 9c65baf7b..8e9f9d1e7 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/Index.cshtml +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Create.Index +@model IdentityServerHost.Pages.Account.Create.Index - \ No newline at end of file + diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/Index.cshtml.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/Index.cshtml.cs index 73f4fff68..826109bb8 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/Index.cshtml.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Create; +namespace IdentityServerHost.Pages.Account.Create; [SecurityHeaders] [AllowAnonymous] diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/InputModel.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/InputModel.cs index b410949e3..68cdcbaeb 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/InputModel.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Create/InputModel.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace IdentityServerHost.Pages.Create; +namespace IdentityServerHost.Pages.Account.Create; public class InputModel { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/Index.cshtml b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/Index.cshtml index 1ec5ae3f1..ea6287f49 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/Index.cshtml +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Login.Index +@model IdentityServerHost.Pages.Account.Login.Index - \ No newline at end of file + diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/Index.cshtml.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/Index.cshtml.cs index ecdddd5c1..71a8604ec 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/Index.cshtml.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; [SecurityHeaders] [AllowAnonymous] diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/InputModel.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/InputModel.cs index 18c4291b5..6feaaa7df 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/InputModel.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/InputModel.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public class InputModel { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/LoginOptions.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/LoginOptions.cs index 8bbd55222..a2040b7c9 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/LoginOptions.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/LoginOptions.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public static class LoginOptions { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/ViewModel.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/ViewModel.cs index 3daacc708..dd31fb329 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/ViewModel.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Login/ViewModel.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public class ViewModel { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/Index.cshtml b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/Index.cshtml index 2d8c4beb2..f832f94d6 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/Index.cshtml +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Logout.Index +@model IdentityServerHost.Pages.Account.Logout.Index
@@ -14,4 +14,4 @@
-
\ No newline at end of file + diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/Index.cshtml.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/Index.cshtml.cs index bcad6c158..908b81fc8 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/Index.cshtml.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; [SecurityHeaders] [AllowAnonymous] diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOut.cshtml b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOut.cshtml index 1169453be..f02a89e5e 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOut.cshtml +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOut.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Logout.LoggedOut +@model IdentityServerHost.Pages.Account.Logout.LoggedOut

@@ -27,4 +27,4 @@ { } -} \ No newline at end of file +} diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOut.cshtml.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOut.cshtml.cs index 1b67b0857..cb308a835 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOut.cshtml.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOut.cshtml.cs @@ -2,7 +2,7 @@ using Duende.IdentityServer.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; [SecurityHeaders] [AllowAnonymous] diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOutViewModel.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOutViewModel.cs index e45de4031..07826af80 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOutViewModel.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LoggedOutViewModel.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; public class LoggedOutViewModel { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LogoutOptions.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LogoutOptions.cs index f4d08bda0..84ee205ee 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LogoutOptions.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Account/Logout/LogoutOptions.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; public static class LogoutOptions { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Diagnostics/ViewModel.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Diagnostics/ViewModel.cs index 2b460a4d3..93c431713 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Diagnostics/ViewModel.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Diagnostics/ViewModel.cs @@ -1,6 +1,6 @@ +using System.Buffers.Text; using System.Text; using System.Text.Json; -using Duende.IdentityModel; using Microsoft.AspNetCore.Authentication; namespace IdentityServerHost.Pages.Diagnostics; @@ -25,5 +25,6 @@ public class ViewModel } public AuthenticateResult AuthenticateResult { get; } + public IEnumerable Clients { get; } } diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Error/Index.cshtml b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Error/Index.cshtml similarity index 100% rename from identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Error/Index.cshtml rename to identity-server/templates/src/IdentityServerEntityFramework/Pages/Error/Index.cshtml diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Error/Index.cshtml.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Error/Index.cshtml.cs similarity index 100% rename from identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Error/Index.cshtml.cs rename to identity-server/templates/src/IdentityServerEntityFramework/Pages/Error/Index.cshtml.cs diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Error/ViewModel.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Error/ViewModel.cs similarity index 100% rename from identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Error/ViewModel.cs rename to identity-server/templates/src/IdentityServerEntityFramework/Pages/Error/ViewModel.cs diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml similarity index 97% rename from identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml rename to identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml index fff93e68e..efa870841 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Home.Index +@model IdentityServerHost.Pages.Index

diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml.cs similarity index 93% rename from identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml.cs rename to identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml.cs index d8aa6f404..03db09a07 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml.cs @@ -3,7 +3,7 @@ using Duende.IdentityServer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Home; +namespace IdentityServerHost.Pages; [AllowAnonymous] public class Index : PageModel diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/TestUsers.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/TestUsers.cs index a7499339e..05bf9336f 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/TestUsers.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/TestUsers.cs @@ -4,7 +4,7 @@ using Duende.IdentityModel; using Duende.IdentityServer; using Duende.IdentityServer.Test; -namespace IdentityServerHost; +namespace IdentityServerHost.Pages; public static class TestUsers { diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/_ViewImports.cshtml b/identity-server/templates/src/IdentityServerEntityFramework/Pages/_ViewImports.cshtml index 7537d10a8..afa82bbf2 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Pages/_ViewImports.cshtml +++ b/identity-server/templates/src/IdentityServerEntityFramework/Pages/_ViewImports.cshtml @@ -1,2 +1 @@ -@using IdentityServerHost.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Program.cs b/identity-server/templates/src/IdentityServerEntityFramework/Program.cs index 1c7f85514..86f76f558 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/Program.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/Program.cs @@ -1,7 +1,7 @@ using System.Globalization; using System.Text; using Duende.IdentityServer.Licensing; -using IdentityServerEntityFramework; +using IdentityServerHost; using Serilog; Log.Logger = new LoggerConfiguration() diff --git a/identity-server/templates/src/IdentityServerEntityFramework/SeedData.cs b/identity-server/templates/src/IdentityServerEntityFramework/SeedData.cs index 0b9d7e185..d4b88dc5d 100644 --- a/identity-server/templates/src/IdentityServerEntityFramework/SeedData.cs +++ b/identity-server/templates/src/IdentityServerEntityFramework/SeedData.cs @@ -4,7 +4,7 @@ using Duende.IdentityServer.Models; using Microsoft.EntityFrameworkCore; using Serilog; -namespace IdentityServerEntityFramework; +namespace IdentityServerHost; public class SeedData { From 923a352ae201cfee1ca37f37095d7004aa1d6508 Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:29:26 +0100 Subject: [PATCH 04/11] IdentityServerInMem : Fix Base64Url and align namespaces on "IdentityServerHost" --- .../src/IdentityServerInMem/Config.cs | 2 +- .../IdentityServerInMem/HostingExtensions.cs | 4 +- .../IdentityServerInMem.csproj | 2 +- .../Pages/Account/Create/Index.cshtml | 4 +- .../Pages/Account/Create/Index.cshtml.cs | 24 ++++------ .../Pages/Account/Create/InputModel.cs | 2 +- .../Pages/Account/Login/Index.cshtml | 4 +- .../Pages/Account/Login/Index.cshtml.cs | 48 +++++++------------ .../Pages/Account/Login/InputModel.cs | 2 +- .../Pages/Account/Login/LoginOptions.cs | 2 +- .../Pages/Account/Login/ViewModel.cs | 14 ++---- .../Pages/Account/Logout/Index.cshtml | 4 +- .../Pages/Account/Logout/Index.cshtml.cs | 20 +++----- .../Pages/Account/Logout/LoggedOut.cshtml | 4 +- .../Pages/Account/Logout/LoggedOut.cshtml.cs | 10 ++-- .../Account/Logout/LoggedOutViewModel.cs | 2 +- .../Pages/Account/Logout/LogoutOptions.cs | 2 +- .../Pages/Ciba/All.cshtml.cs | 9 ++-- .../Pages/Ciba/Consent.cshtml.cs | 34 +++++-------- .../Pages/Ciba/Index.cshtml.cs | 18 +++---- .../Pages/Consent/Index.cshtml.cs | 32 +++++-------- .../Pages/Device/Index.cshtml.cs | 30 +++++------- .../Pages/Diagnostics/ViewModel.cs | 2 +- .../Pages/{Home => }/Error/Index.cshtml | 0 .../Pages/{Home => }/Error/Index.cshtml.cs | 18 ++----- .../Pages/{Home => }/Error/ViewModel.cs | 0 .../Pages/ExternalLogin/Callback.cshtml.cs | 34 +++++-------- .../Pages/ExternalLogin/Challenge.cshtml.cs | 8 +--- .../Pages/Grants/Index.cshtml.cs | 37 +++++--------- .../IdentityServerInMem/Pages/Index.cshtml | 2 +- .../IdentityServerInMem/Pages/Index.cshtml.cs | 14 +++--- .../Pages/ServerSideSessions/Index.cshtml.cs | 14 ++---- .../IdentityServerInMem/Pages/TestUsers.cs | 2 +- .../Pages/_ViewImports.cshtml | 3 +- .../src/IdentityServerInMem/Program.cs | 2 +- 35 files changed, 148 insertions(+), 261 deletions(-) rename identity-server/templates/src/IdentityServerInMem/Pages/{Home => }/Error/Index.cshtml (100%) rename identity-server/templates/src/IdentityServerInMem/Pages/{Home => }/Error/Index.cshtml.cs (50%) rename identity-server/templates/src/IdentityServerInMem/Pages/{Home => }/Error/ViewModel.cs (100%) diff --git a/identity-server/templates/src/IdentityServerInMem/Config.cs b/identity-server/templates/src/IdentityServerInMem/Config.cs index 4e89381a2..731e829e0 100644 --- a/identity-server/templates/src/IdentityServerInMem/Config.cs +++ b/identity-server/templates/src/IdentityServerInMem/Config.cs @@ -1,6 +1,6 @@ using Duende.IdentityServer.Models; -namespace IdentityServerInMem; +namespace IdentityServerHost; public static class Config { diff --git a/identity-server/templates/src/IdentityServerInMem/HostingExtensions.cs b/identity-server/templates/src/IdentityServerInMem/HostingExtensions.cs index 4a6dcb42e..60d085aa2 100644 --- a/identity-server/templates/src/IdentityServerInMem/HostingExtensions.cs +++ b/identity-server/templates/src/IdentityServerInMem/HostingExtensions.cs @@ -1,11 +1,11 @@ using System.Globalization; using Duende.IdentityServer; -using IdentityServerHost; +using IdentityServerHost.Pages; using Microsoft.IdentityModel.Tokens; using Serilog; using Serilog.Filters; -namespace IdentityServerInMem; +namespace IdentityServerHost; internal static class HostingExtensions { diff --git a/identity-server/templates/src/IdentityServerInMem/IdentityServerInMem.csproj b/identity-server/templates/src/IdentityServerInMem/IdentityServerInMem.csproj index 774d4caca..1b4989bb4 100644 --- a/identity-server/templates/src/IdentityServerInMem/IdentityServerInMem.csproj +++ b/identity-server/templates/src/IdentityServerInMem/IdentityServerInMem.csproj @@ -4,6 +4,7 @@ net10.0 enable enable + IdentityServerHost @@ -11,5 +12,4 @@ - diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/Index.cshtml b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/Index.cshtml index 9c65baf7b..8e9f9d1e7 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/Index.cshtml +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Create.Index +@model IdentityServerHost.Pages.Account.Create.Index -

\ No newline at end of file +

diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/Index.cshtml.cs index 73f4fff68..d6e6e7cd4 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/Index.cshtml.cs @@ -6,27 +6,21 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Create; +namespace IdentityServerHost.Pages.Account.Create; [SecurityHeaders] [AllowAnonymous] -public class Index : PageModel +public class Index( + IIdentityServerInteractionService interaction, + TestUserStore? users = null) + : PageModel { - private readonly TestUserStore _users; - private readonly IIdentityServerInteractionService _interaction; + private readonly TestUserStore _users = users ?? throw new InvalidOperationException("Please call 'AddTestUsers(TestUsers.Users)' on the IIdentityServerBuilder in Startup or remove the TestUserStore from the AccountController."); [BindProperty] public InputModel Input { get; set; } = default!; - public Index( - IIdentityServerInteractionService interaction, - TestUserStore? users = null) - { - // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity) - _users = users ?? throw new InvalidOperationException("Please call 'AddTestUsers(TestUsers.Users)' on the IIdentityServerBuilder in Startup or remove the TestUserStore from the AccountController."); - - _interaction = interaction; - } + // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity) public IActionResult OnGet(string? returnUrl) { @@ -37,7 +31,7 @@ public class Index : PageModel public async Task OnPost() { // check if we are in the context of an authorization request - var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl); + var context = await interaction.GetAuthorizationContextAsync(Input.ReturnUrl); // the user clicked the "cancel" button if (Input.Button != "create") @@ -47,7 +41,7 @@ public class Index : PageModel // if the user cancels, send a result back into IdentityServer as if they // denied the consent (even if this client does not require consent). // this will send back an access denied OIDC error response to the client. - await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied); + await interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied); // we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null if (context.IsNativeClient()) diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/InputModel.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/InputModel.cs index b410949e3..68cdcbaeb 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/InputModel.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Create/InputModel.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace IdentityServerHost.Pages.Create; +namespace IdentityServerHost.Pages.Account.Create; public class InputModel { diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/Index.cshtml b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/Index.cshtml index 1ec5ae3f1..ea6287f49 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/Index.cshtml +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Login.Index +@model IdentityServerHost.Pages.Account.Login.Index - \ No newline at end of file + diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/Index.cshtml.cs index ecdddd5c1..18d557a2e 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/Index.cshtml.cs @@ -9,38 +9,26 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; [SecurityHeaders] [AllowAnonymous] -public class Index : PageModel +public class Index( + IIdentityServerInteractionService interaction, + IAuthenticationSchemeProvider schemeProvider, + IIdentityProviderStore identityProviderStore, + IEventService events, + TestUserStore? users = null) + : PageModel { - private readonly TestUserStore _users; - private readonly IIdentityServerInteractionService _interaction; - private readonly IEventService _events; - private readonly IAuthenticationSchemeProvider _schemeProvider; - private readonly IIdentityProviderStore _identityProviderStore; + private readonly TestUserStore _users = users ?? throw new InvalidOperationException("Please call 'AddTestUsers(TestUsers.Users)' on the IIdentityServerBuilder in Startup or remove the TestUserStore from the AccountController."); public ViewModel View { get; set; } = default!; [BindProperty] public InputModel Input { get; set; } = default!; - public Index( - IIdentityServerInteractionService interaction, - IAuthenticationSchemeProvider schemeProvider, - IIdentityProviderStore identityProviderStore, - IEventService events, - TestUserStore? users = null) - { - // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity) - _users = users ?? throw new InvalidOperationException("Please call 'AddTestUsers(TestUsers.Users)' on the IIdentityServerBuilder in Startup or remove the TestUserStore from the AccountController."); - - _interaction = interaction; - _schemeProvider = schemeProvider; - _identityProviderStore = identityProviderStore; - _events = events; - } + // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity) public async Task OnGet(string? returnUrl) { @@ -58,7 +46,7 @@ public class Index : PageModel public async Task OnPost() { // check if we are in the context of an authorization request - var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl); + var context = await interaction.GetAuthorizationContextAsync(Input.ReturnUrl); // the user clicked the "cancel" button if (Input.Button != "login") @@ -71,7 +59,7 @@ public class Index : PageModel // if the user cancels, send a result back into IdentityServer as if they // denied the consent (even if this client does not require consent). // this will send back an access denied OIDC error response to the client. - await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied); + await interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied); // we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null if (context.IsNativeClient()) @@ -96,7 +84,7 @@ public class Index : PageModel if (_users.ValidateCredentials(Input.Username, Input.Password)) { var user = _users.FindByUsername(Input.Username); - await _events.RaiseAsync(new UserLoginSuccessEvent(user.Username, user.SubjectId, user.Username, clientId: context?.Client.ClientId)); + await events.RaiseAsync(new UserLoginSuccessEvent(user.Username, user.SubjectId, user.Username, clientId: context?.Client.ClientId)); Telemetry.Metrics.UserLogin(context?.Client.ClientId, IdentityServerConstants.LocalIdentityProvider); // only set explicit expiration here if user chooses "remember me". @@ -149,7 +137,7 @@ public class Index : PageModel } const string error = "invalid credentials"; - await _events.RaiseAsync(new UserLoginFailureEvent(Input.Username, error, clientId: context?.Client.ClientId)); + await events.RaiseAsync(new UserLoginFailureEvent(Input.Username, error, clientId: context?.Client.ClientId)); Telemetry.Metrics.UserLoginFailure(context?.Client.ClientId, IdentityServerConstants.LocalIdentityProvider, error); ModelState.AddModelError(string.Empty, LoginOptions.InvalidCredentialsErrorMessage); } @@ -166,10 +154,10 @@ public class Index : PageModel ReturnUrl = returnUrl }; - var context = await _interaction.GetAuthorizationContextAsync(returnUrl); + var context = await interaction.GetAuthorizationContextAsync(returnUrl); if (context?.IdP != null) { - var scheme = await _schemeProvider.GetSchemeAsync(context.IdP); + var scheme = await schemeProvider.GetSchemeAsync(context.IdP); if (scheme != null) { var local = context.IdP == Duende.IdentityServer.IdentityServerConstants.LocalIdentityProvider; @@ -191,7 +179,7 @@ public class Index : PageModel return; } - var schemes = await _schemeProvider.GetAllSchemesAsync(); + var schemes = await schemeProvider.GetAllSchemesAsync(); var providers = schemes .Where(x => x.DisplayName != null) @@ -201,7 +189,7 @@ public class Index : PageModel displayName: x.DisplayName ?? x.Name )).ToList(); - var dynamicSchemes = (await _identityProviderStore.GetAllSchemeNamesAsync()) + var dynamicSchemes = (await identityProviderStore.GetAllSchemeNamesAsync()) .Where(x => x.Enabled) .Select(x => new ViewModel.ExternalProvider ( diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/InputModel.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/InputModel.cs index 18c4291b5..6feaaa7df 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/InputModel.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/InputModel.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public class InputModel { diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/LoginOptions.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/LoginOptions.cs index 8bbd55222..a2040b7c9 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/LoginOptions.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/LoginOptions.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public static class LoginOptions { diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/ViewModel.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/ViewModel.cs index 3daacc708..9a60cf6af 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/ViewModel.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Login/ViewModel.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public class ViewModel { @@ -11,15 +11,9 @@ public class ViewModel public bool IsExternalLoginOnly => EnableLocalLogin == false && ExternalProviders?.Count() == 1; public string? ExternalLoginScheme => IsExternalLoginOnly ? ExternalProviders?.SingleOrDefault()?.AuthenticationScheme : null; - public class ExternalProvider + public class ExternalProvider(string authenticationScheme, string? displayName = null) { - public ExternalProvider(string authenticationScheme, string? displayName = null) - { - AuthenticationScheme = authenticationScheme; - DisplayName = displayName; - } - - public string? DisplayName { get; set; } - public string AuthenticationScheme { get; set; } + public string? DisplayName { get; set; } = displayName; + public string AuthenticationScheme { get; set; } = authenticationScheme; } } diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/Index.cshtml b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/Index.cshtml index 2d8c4beb2..f832f94d6 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/Index.cshtml +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Logout.Index +@model IdentityServerHost.Pages.Account.Logout.Index
@@ -14,4 +14,4 @@
-
\ No newline at end of file + diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/Index.cshtml.cs index bcad6c158..f7e7d5bb5 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/Index.cshtml.cs @@ -7,24 +7,16 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; [SecurityHeaders] [AllowAnonymous] -public class Index : PageModel +public class Index(IIdentityServerInteractionService interaction, IEventService events) + : PageModel { - private readonly IIdentityServerInteractionService _interaction; - private readonly IEventService _events; - [BindProperty] public string? LogoutId { get; set; } - public Index(IIdentityServerInteractionService interaction, IEventService events) - { - _interaction = interaction; - _events = events; - } - public async Task OnGet(string? logoutId) { LogoutId = logoutId; @@ -38,7 +30,7 @@ public class Index : PageModel } else { - var context = await _interaction.GetLogoutContextAsync(LogoutId); + var context = await interaction.GetLogoutContextAsync(LogoutId); if (context?.ShowSignoutPrompt == false) { // it's safe to automatically sign-out @@ -63,7 +55,7 @@ public class Index : PageModel // if there's no current logout context, we need to create one // this captures necessary info from the current logged in user // this can still return null if there is no context needed - LogoutId ??= await _interaction.CreateLogoutContextAsync(); + LogoutId ??= await interaction.CreateLogoutContextAsync(); // delete local authentication cookie await HttpContext.SignOutAsync(); @@ -72,7 +64,7 @@ public class Index : PageModel var idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value; // raise the logout event - await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); + await events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName())); Telemetry.Metrics.UserLogout(idp); // if it's a local login we can ignore this workflow diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOut.cshtml b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOut.cshtml index 1169453be..f02a89e5e 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOut.cshtml +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOut.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Logout.LoggedOut +@model IdentityServerHost.Pages.Account.Logout.LoggedOut

@@ -27,4 +27,4 @@ { } -} \ No newline at end of file +} diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOut.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOut.cshtml.cs index 1b67b0857..7adb4716d 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOut.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOut.cshtml.cs @@ -2,22 +2,18 @@ using Duende.IdentityServer.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; [SecurityHeaders] [AllowAnonymous] -public class LoggedOut : PageModel +public class LoggedOut(IIdentityServerInteractionService interactionService) : PageModel { - private readonly IIdentityServerInteractionService _interactionService; - public LoggedOutViewModel View { get; set; } = default!; - public LoggedOut(IIdentityServerInteractionService interactionService) => _interactionService = interactionService; - public async Task OnGet(string? logoutId) { // get context information (client name, post logout redirect URI and iframe for federated signout) - var logout = await _interactionService.GetLogoutContextAsync(logoutId); + var logout = await interactionService.GetLogoutContextAsync(logoutId); View = new LoggedOutViewModel { diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOutViewModel.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOutViewModel.cs index e45de4031..07826af80 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOutViewModel.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LoggedOutViewModel.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; public class LoggedOutViewModel { diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LogoutOptions.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LogoutOptions.cs index f4d08bda0..84ee205ee 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LogoutOptions.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Account/Logout/LogoutOptions.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; public static class LogoutOptions { diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/All.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/All.cshtml.cs index fc69e4dee..7dd2bf202 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/All.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/All.cshtml.cs @@ -7,13 +7,10 @@ namespace IdentityServerHost.Pages.Ciba; [SecurityHeaders] [Authorize] -public class AllModel : PageModel +public class AllModel(IBackchannelAuthenticationInteractionService backchannelAuthenticationInteractionService) + : PageModel { public IEnumerable Logins { get; set; } = default!; - private readonly IBackchannelAuthenticationInteractionService _backchannelAuthenticationInteraction; - - public AllModel(IBackchannelAuthenticationInteractionService backchannelAuthenticationInteractionService) => _backchannelAuthenticationInteraction = backchannelAuthenticationInteractionService; - - public async Task OnGet() => Logins = await _backchannelAuthenticationInteraction.GetPendingLoginRequestsForCurrentUserAsync(); + public async Task OnGet() => Logins = await backchannelAuthenticationInteractionService.GetPendingLoginRequestsForCurrentUserAsync(); } diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/Consent.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/Consent.cshtml.cs index 7e2ae5983..c722632e1 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/Consent.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/Consent.cshtml.cs @@ -11,22 +11,12 @@ namespace IdentityServerHost.Pages.Ciba; [Authorize] [SecurityHeaders] -public class Consent : PageModel +public class Consent( + IBackchannelAuthenticationInteractionService interaction, + IEventService events, + ILogger logger) + : PageModel { - private readonly IBackchannelAuthenticationInteractionService _interaction; - private readonly IEventService _events; - private readonly ILogger _logger; - - public Consent( - IBackchannelAuthenticationInteractionService interaction, - IEventService events, - ILogger logger) - { - _interaction = interaction; - _events = events; - _logger = logger; - } - public ViewModel View { get; set; } = default!; [BindProperty] @@ -50,10 +40,10 @@ public class Consent : PageModel public async Task OnPost() { // validate return url is still valid - var request = await _interaction.GetLoginRequestByInternalIdAsync(Input.Id ?? throw new ArgumentNullException(nameof(Input.Id))); + var request = await interaction.GetLoginRequestByInternalIdAsync(Input.Id ?? throw new ArgumentNullException(nameof(Input.Id))); if (request == null || request.Subject.GetSubjectId() != User.GetSubjectId()) { - _logger.InvalidId(Input.Id); + logger.InvalidId(Input.Id); return RedirectToPage("/Home/Error/Index"); } @@ -65,7 +55,7 @@ public class Consent : PageModel result = new CompleteBackchannelLoginRequest(Input.Id); // emit event - await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues)); + await events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues)); Telemetry.Metrics.ConsentDenied(request.Client.ClientId, request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName)); } // user clicked 'yes' - validate the data @@ -87,7 +77,7 @@ public class Consent : PageModel }; // emit event - await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, result.ScopesValuesConsented, false)); + await events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, result.ScopesValuesConsented, false)); Telemetry.Metrics.ConsentGranted(request.Client.ClientId, result.ScopesValuesConsented, false); var denied = request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName).Except(result.ScopesValuesConsented); Telemetry.Metrics.ConsentDenied(request.Client.ClientId, denied); @@ -105,7 +95,7 @@ public class Consent : PageModel if (result != null) { // communicate outcome of consent back to identityserver - await _interaction.CompleteLoginRequestAsync(result); + await interaction.CompleteLoginRequestAsync(result); return RedirectToPage("/Ciba/All"); } @@ -122,7 +112,7 @@ public class Consent : PageModel { ArgumentNullException.ThrowIfNull(id); - var request = await _interaction.GetLoginRequestByInternalIdAsync(id); + var request = await interaction.GetLoginRequestByInternalIdAsync(id); if (request != null && request.Subject.GetSubjectId() == User.GetSubjectId()) { View = CreateConsentViewModel(request); @@ -130,7 +120,7 @@ public class Consent : PageModel } else { - _logger.NoMatchingBackchannelLoginRequest(id); + logger.NoMatchingBackchannelLoginRequest(id); return false; } } diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/Index.cshtml.cs index 733bc84ea..f2c11c2fd 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Ciba/Index.cshtml.cs @@ -8,25 +8,19 @@ namespace IdentityServerHost.Pages.Ciba; [AllowAnonymous] [SecurityHeaders] -public class IndexModel : PageModel +public class IndexModel( + IBackchannelAuthenticationInteractionService backchannelAuthenticationInteractionService, + ILogger logger) + : PageModel { public BackchannelUserLoginRequest LoginRequest { get; set; } = default!; - private readonly IBackchannelAuthenticationInteractionService _backchannelAuthenticationInteraction; - private readonly ILogger _logger; - - public IndexModel(IBackchannelAuthenticationInteractionService backchannelAuthenticationInteractionService, ILogger logger) - { - _backchannelAuthenticationInteraction = backchannelAuthenticationInteractionService; - _logger = logger; - } - public async Task OnGet(string id) { - var result = await _backchannelAuthenticationInteraction.GetLoginRequestByInternalIdAsync(id); + var result = await backchannelAuthenticationInteractionService.GetLoginRequestByInternalIdAsync(id); if (result == null) { - _logger.InvalidBackchannelLoginId(id); + logger.InvalidBackchannelLoginId(id); return RedirectToPage("/Home/Error/Index"); } else diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Consent/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Consent/Index.cshtml.cs index b60dc22be..c4ad5ef4d 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Consent/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Consent/Index.cshtml.cs @@ -12,22 +12,12 @@ namespace IdentityServerHost.Pages.Consent; [Authorize] [SecurityHeaders] -public class Index : PageModel +public class Index( + IIdentityServerInteractionService interaction, + IEventService events, + ILogger logger) + : PageModel { - private readonly IIdentityServerInteractionService _interaction; - private readonly IEventService _events; - private readonly ILogger _logger; - - public Index( - IIdentityServerInteractionService interaction, - IEventService events, - ILogger logger) - { - _interaction = interaction; - _events = events; - _logger = logger; - } - public ViewModel View { get; set; } = default!; [BindProperty] @@ -51,7 +41,7 @@ public class Index : PageModel public async Task OnPost() { // validate return url is still valid - var request = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl); + var request = await interaction.GetAuthorizationContextAsync(Input.ReturnUrl); if (request == null) { return RedirectToPage("/Home/Error/Index"); @@ -65,7 +55,7 @@ public class Index : PageModel grantedConsent = new ConsentResponse { Error = AuthorizationError.AccessDenied }; // emit event - await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues)); + await events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues)); Telemetry.Metrics.ConsentDenied(request.Client.ClientId, request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName)); } // user clicked 'yes' - validate the data @@ -88,7 +78,7 @@ public class Index : PageModel }; // emit event - await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent)); + await events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent)); Telemetry.Metrics.ConsentGranted(request.Client.ClientId, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent); var denied = request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName).Except(grantedConsent.ScopesValuesConsented); Telemetry.Metrics.ConsentDenied(request.Client.ClientId, denied); @@ -108,7 +98,7 @@ public class Index : PageModel ArgumentNullException.ThrowIfNull(Input.ReturnUrl, nameof(Input.ReturnUrl)); // communicate outcome of consent back to identityserver - await _interaction.GrantConsentAsync(request, grantedConsent); + await interaction.GrantConsentAsync(request, grantedConsent); // redirect back to authorization endpoint if (request.IsNativeClient() == true) @@ -133,7 +123,7 @@ public class Index : PageModel { ArgumentNullException.ThrowIfNull(returnUrl); - var request = await _interaction.GetAuthorizationContextAsync(returnUrl); + var request = await interaction.GetAuthorizationContextAsync(returnUrl); if (request != null) { View = CreateConsentViewModel(request); @@ -141,7 +131,7 @@ public class Index : PageModel } else { - _logger.NoConsentMatchingRequest(returnUrl); + logger.NoConsentMatchingRequest(returnUrl); return false; } } diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Device/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Device/Index.cshtml.cs index 273989303..c0f16a7f7 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Device/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Device/Index.cshtml.cs @@ -14,21 +14,13 @@ namespace IdentityServerHost.Pages.Device; [SecurityHeaders] [Authorize] -public class Index : PageModel +public class Index( + IDeviceFlowInteractionService interaction, + IEventService eventService, + IOptions options) + : PageModel { - private readonly IDeviceFlowInteractionService _interaction; - private readonly IEventService _events; - private readonly IOptions _options; - - public Index( - IDeviceFlowInteractionService interaction, - IEventService eventService, - IOptions options) - { - _interaction = interaction; - _events = eventService; - _options = options; - } + private readonly IOptions _options = options; public ViewModel View { get; set; } = default!; @@ -58,7 +50,7 @@ public class Index : PageModel public async Task OnPost() { - var request = await _interaction.GetAuthorizationContextAsync(Input.UserCode ?? throw new ArgumentNullException(nameof(Input.UserCode))); + var request = await interaction.GetAuthorizationContextAsync(Input.UserCode ?? throw new ArgumentNullException(nameof(Input.UserCode))); if (request == null) { return RedirectToPage("/Home/Error/Index"); @@ -75,7 +67,7 @@ public class Index : PageModel }; // emit event - await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues)); + await eventService.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues)); Telemetry.Metrics.ConsentDenied(request.Client.ClientId, request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName)); } // user clicked 'yes' - validate the data @@ -98,7 +90,7 @@ public class Index : PageModel }; // emit event - await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent)); + await eventService.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent)); Telemetry.Metrics.ConsentGranted(request.Client.ClientId, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent); var denied = request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName).Except(grantedConsent.ScopesValuesConsented); Telemetry.Metrics.ConsentDenied(request.Client.ClientId, denied); @@ -116,7 +108,7 @@ public class Index : PageModel if (grantedConsent != null) { // communicate outcome of consent back to identityserver - await _interaction.HandleRequestAsync(Input.UserCode, grantedConsent); + await interaction.HandleRequestAsync(Input.UserCode, grantedConsent); // indicate that's it ok to redirect back to authorization endpoint return RedirectToPage("/Device/Success"); @@ -133,7 +125,7 @@ public class Index : PageModel private async Task SetViewModelAsync(string userCode) { - var request = await _interaction.GetAuthorizationContextAsync(userCode); + var request = await interaction.GetAuthorizationContextAsync(userCode); if (request != null) { View = CreateConsentViewModel(request); diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs index 64f46488d..d565497d3 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Diagnostics/ViewModel.cs @@ -1,6 +1,6 @@ +using System.Buffers.Text; using System.Text; using System.Text.Json; -using Duende.IdentityModel; using Microsoft.AspNetCore.Authentication; namespace IdentityServerHost.Pages.Diagnostics; diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Home/Error/Index.cshtml b/identity-server/templates/src/IdentityServerInMem/Pages/Error/Index.cshtml similarity index 100% rename from identity-server/templates/src/IdentityServerInMem/Pages/Home/Error/Index.cshtml rename to identity-server/templates/src/IdentityServerInMem/Pages/Error/Index.cshtml diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Home/Error/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Error/Index.cshtml.cs similarity index 50% rename from identity-server/templates/src/IdentityServerInMem/Pages/Home/Error/Index.cshtml.cs rename to identity-server/templates/src/IdentityServerInMem/Pages/Error/Index.cshtml.cs index 5102cfc93..73aa342a6 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Home/Error/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Error/Index.cshtml.cs @@ -6,28 +6,20 @@ namespace IdentityServerHost.Pages.Error; [AllowAnonymous] [SecurityHeaders] -public class Index : PageModel +public class Index(IIdentityServerInteractionService interaction, IWebHostEnvironment environment) + : PageModel { - private readonly IIdentityServerInteractionService _interaction; - private readonly IWebHostEnvironment _environment; - public ViewModel View { get; set; } = new(); - public Index(IIdentityServerInteractionService interaction, IWebHostEnvironment environment) - { - _interaction = interaction; - _environment = environment; - } - public async Task OnGet(string? errorId) { - // retrieve error details from identityserver - var message = await _interaction.GetErrorContextAsync(errorId); + // retrieve error details from IdentityServer + var message = await interaction.GetErrorContextAsync(errorId); if (message != null) { View.Error = message; - if (!_environment.IsDevelopment()) + if (!environment.IsDevelopment()) { // only show in development message.ErrorDescription = null; diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Home/Error/ViewModel.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Error/ViewModel.cs similarity index 100% rename from identity-server/templates/src/IdentityServerInMem/Pages/Home/Error/ViewModel.cs rename to identity-server/templates/src/IdentityServerInMem/Pages/Error/ViewModel.cs diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/ExternalLogin/Callback.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/ExternalLogin/Callback.cshtml.cs index 6291d2378..f3639f4a8 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/ExternalLogin/Callback.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/ExternalLogin/Callback.cshtml.cs @@ -13,26 +13,16 @@ namespace IdentityServerHost.Pages.ExternalLogin; [AllowAnonymous] [SecurityHeaders] -public class Callback : PageModel +public class Callback( + IIdentityServerInteractionService interaction, + IEventService events, + ILogger logger, + TestUserStore? users = null) + : PageModel { - private readonly TestUserStore _users; - private readonly IIdentityServerInteractionService _interaction; - private readonly ILogger _logger; - private readonly IEventService _events; + private readonly TestUserStore _users = users ?? throw new InvalidOperationException("Please call 'AddTestUsers(TestUsers.Users)' on the IIdentityServerBuilder in Startup or remove the TestUserStore from the AccountController."); - public Callback( - IIdentityServerInteractionService interaction, - IEventService events, - ILogger logger, - TestUserStore? users = null) - { - // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity) - _users = users ?? throw new InvalidOperationException("Please call 'AddTestUsers(TestUsers.Users)' on the IIdentityServerBuilder in Startup or remove the TestUserStore from the AccountController."); - - _interaction = interaction; - _logger = logger; - _events = events; - } + // this is where you would plug in your own custom identity management library (e.g. ASP.NET Identity) public async Task OnGet() { @@ -46,10 +36,10 @@ public class Callback : PageModel var externalUser = result.Principal ?? throw new InvalidOperationException("External authentication produced a null Principal"); - if (_logger.IsEnabled(LogLevel.Debug)) + if (logger.IsEnabled(LogLevel.Debug)) { var externalClaims = externalUser.Claims.Select(c => $"{c.Type}: {c.Value}"); - _logger.ExternalClaims(externalClaims); + logger.ExternalClaims(externalClaims); } // lookup our user and external provider info @@ -101,8 +91,8 @@ public class Callback : PageModel var returnUrl = result.Properties.Items["returnUrl"] ?? "~/"; // check if external login is in the context of an OIDC request - var context = await _interaction.GetAuthorizationContextAsync(returnUrl); - await _events.RaiseAsync(new UserLoginSuccessEvent(provider, providerUserId, user.SubjectId, user.Username, true, context?.Client.ClientId)); + var context = await interaction.GetAuthorizationContextAsync(returnUrl); + await events.RaiseAsync(new UserLoginSuccessEvent(provider, providerUserId, user.SubjectId, user.Username, true, context?.Client.ClientId)); Telemetry.Metrics.UserLogin(context?.Client.ClientId, provider!); if (context != null) diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/ExternalLogin/Challenge.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/ExternalLogin/Challenge.cshtml.cs index 865583f15..3b00c4a5e 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/ExternalLogin/Challenge.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/ExternalLogin/Challenge.cshtml.cs @@ -8,12 +8,8 @@ namespace IdentityServerHost.Pages.ExternalLogin; [AllowAnonymous] [SecurityHeaders] -public class Challenge : PageModel +public class Challenge(IIdentityServerInteractionService interactionService) : PageModel { - private readonly IIdentityServerInteractionService _interactionService; - - public Challenge(IIdentityServerInteractionService interactionService) => _interactionService = interactionService; - public IActionResult OnGet(string scheme, string? returnUrl) { if (string.IsNullOrEmpty(returnUrl)) @@ -22,7 +18,7 @@ public class Challenge : PageModel } // Abort on incorrect returnUrl - it is neither a local url nor a valid OIDC url. - if (Url.IsLocalUrl(returnUrl) == false && _interactionService.IsValidReturnUrl(returnUrl) == false) + if (Url.IsLocalUrl(returnUrl) == false && interactionService.IsValidReturnUrl(returnUrl) == false) { // user might have clicked on a malicious link - should be logged throw new ArgumentException("invalid return URL"); diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Grants/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Grants/Index.cshtml.cs index 75e4f15bb..8ca745025 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Grants/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Grants/Index.cshtml.cs @@ -10,37 +10,26 @@ namespace IdentityServerHost.Pages.Grants; [SecurityHeaders] [Authorize] -public class Index : PageModel +public class Index( + IIdentityServerInteractionService interaction, + IClientStore clients, + IResourceStore resources, + IEventService events) + : PageModel { - private readonly IIdentityServerInteractionService _interaction; - private readonly IClientStore _clients; - private readonly IResourceStore _resources; - private readonly IEventService _events; - - public Index(IIdentityServerInteractionService interaction, - IClientStore clients, - IResourceStore resources, - IEventService events) - { - _interaction = interaction; - _clients = clients; - _resources = resources; - _events = events; - } - public ViewModel View { get; set; } = default!; public async Task OnGet() { - var grants = await _interaction.GetAllUserGrantsAsync(); + var grants = await interaction.GetAllUserGrantsAsync(); var list = new List(); foreach (var grant in grants) { - var client = await _clients.FindClientByIdAsync(grant.ClientId); + var client = await clients.FindClientByIdAsync(grant.ClientId); if (client != null) { - var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes); + var resources1 = await resources.FindResourcesByScopeAsync(grant.Scopes); var item = new GrantViewModel() { @@ -51,8 +40,8 @@ public class Index : PageModel Description = grant.Description, Created = grant.CreationTime, Expires = grant.Expiration, - IdentityGrantNames = resources.IdentityResources.Select(x => x.DisplayName ?? x.Name).ToArray(), - ApiGrantNames = resources.ApiScopes.Select(x => x.DisplayName ?? x.Name).ToArray() + IdentityGrantNames = resources1.IdentityResources.Select(x => x.DisplayName ?? x.Name).ToArray(), + ApiGrantNames = resources1.ApiScopes.Select(x => x.DisplayName ?? x.Name).ToArray() }; list.Add(item); @@ -70,8 +59,8 @@ public class Index : PageModel public async Task OnPost() { - await _interaction.RevokeUserConsentAsync(ClientId); - await _events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), ClientId)); + await interaction.RevokeUserConsentAsync(ClientId); + await events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), ClientId)); Telemetry.Metrics.GrantsRevoked(ClientId); return RedirectToPage("/Grants/Index"); diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Index.cshtml b/identity-server/templates/src/IdentityServerInMem/Pages/Index.cshtml index a6e13cbf6..a4c2542a6 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Index.cshtml +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Home.Index +@model IdentityServerHost.Pages.Index

diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/Index.cshtml.cs index 99a272048..3801f1fc4 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/Index.cshtml.cs @@ -3,16 +3,14 @@ using Duende.IdentityServer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Home; +namespace IdentityServerHost.Pages; [AllowAnonymous] -public class Index : PageModel +public class Index(IdentityServerLicense? license = null) : PageModel { - public Index(IdentityServerLicense? license = null) => License = license; - public string Version => typeof(Duende.IdentityServer.Hosting.IdentityServerMiddleware).Assembly - .GetCustomAttribute() - ?.InformationalVersion.Split('+').First() - ?? "unavailable"; - public IdentityServerLicense? License { get; } + .GetCustomAttribute() + ?.InformationalVersion.Split('+').First() + ?? "unavailable"; + public IdentityServerLicense? License { get; } = license; } diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/ServerSideSessions/Index.cshtml.cs b/identity-server/templates/src/IdentityServerInMem/Pages/ServerSideSessions/Index.cshtml.cs index a90ae936b..e7df43575 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/ServerSideSessions/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/ServerSideSessions/Index.cshtml.cs @@ -6,12 +6,8 @@ using Microsoft.AspNetCore.Mvc.RazorPages; namespace IdentityServerHost.Pages.ServerSideSessions; -public class IndexModel : PageModel +public class IndexModel(ISessionManagementService? sessionManagementService = null) : PageModel { - private readonly ISessionManagementService? _sessionManagementService; - - public IndexModel(ISessionManagementService? sessionManagementService = null) => _sessionManagementService = sessionManagementService; - public QueryResult? UserSessions { get; set; } [BindProperty(SupportsGet = true)] @@ -37,9 +33,9 @@ public class IndexModel : PageModel return NotFound(); } - if (_sessionManagementService != null) + if (sessionManagementService != null) { - UserSessions = await _sessionManagementService.QuerySessionsAsync(new SessionQuery + UserSessions = await sessionManagementService.QuerySessionsAsync(new SessionQuery { ResultsToken = Token, RequestPriorResults = Prev == "true", @@ -63,9 +59,9 @@ public class IndexModel : PageModel return NotFound(); } - ArgumentNullException.ThrowIfNull(_sessionManagementService); + ArgumentNullException.ThrowIfNull(sessionManagementService); - await _sessionManagementService.RemoveSessionsAsync(new RemoveSessionsContext + await sessionManagementService.RemoveSessionsAsync(new RemoveSessionsContext { SessionId = SessionId, }); diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/TestUsers.cs b/identity-server/templates/src/IdentityServerInMem/Pages/TestUsers.cs index a7499339e..05bf9336f 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/TestUsers.cs +++ b/identity-server/templates/src/IdentityServerInMem/Pages/TestUsers.cs @@ -4,7 +4,7 @@ using Duende.IdentityModel; using Duende.IdentityServer; using Duende.IdentityServer.Test; -namespace IdentityServerHost; +namespace IdentityServerHost.Pages; public static class TestUsers { diff --git a/identity-server/templates/src/IdentityServerInMem/Pages/_ViewImports.cshtml b/identity-server/templates/src/IdentityServerInMem/Pages/_ViewImports.cshtml index 7537d10a8..afa82bbf2 100644 --- a/identity-server/templates/src/IdentityServerInMem/Pages/_ViewImports.cshtml +++ b/identity-server/templates/src/IdentityServerInMem/Pages/_ViewImports.cshtml @@ -1,2 +1 @@ -@using IdentityServerHost.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/identity-server/templates/src/IdentityServerInMem/Program.cs b/identity-server/templates/src/IdentityServerInMem/Program.cs index 85190f6ae..cdfaf2dce 100644 --- a/identity-server/templates/src/IdentityServerInMem/Program.cs +++ b/identity-server/templates/src/IdentityServerInMem/Program.cs @@ -1,7 +1,7 @@ using System.Globalization; using System.Text; using Duende.IdentityServer.Licensing; -using IdentityServerInMem; +using IdentityServerHost; using Serilog; Log.Logger = new LoggerConfiguration() From dd54cd2b42765783043d3bc9b25806ffdaaa140a Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:30:23 +0100 Subject: [PATCH 05/11] IdentityServerEntityFramework: Move home index bach to /Pages --- .../IdentityServerEntityFramework/Pages/{Home => }/Index.cshtml | 0 .../Pages/{Home => }/Index.cshtml.cs | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename identity-server/templates/src/IdentityServerEntityFramework/Pages/{Home => }/Index.cshtml (100%) rename identity-server/templates/src/IdentityServerEntityFramework/Pages/{Home => }/Index.cshtml.cs (100%) diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml similarity index 100% rename from identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml rename to identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml diff --git a/identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml.cs b/identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml.cs similarity index 100% rename from identity-server/templates/src/IdentityServerEntityFramework/Pages/Home/Index.cshtml.cs rename to identity-server/templates/src/IdentityServerEntityFramework/Pages/Index.cshtml.cs From b0a412e63b79d5525b586a8a7f6499946f593358 Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:32:05 +0100 Subject: [PATCH 06/11] IdentityServerEmpty: Set rootnamespace to "IdentityServerHost" and adjust namespaces --- identity-server/templates/src/IdentityServerEmpty/Config.cs | 2 +- .../templates/src/IdentityServerEmpty/HostingExtensions.cs | 2 +- .../src/IdentityServerEmpty/IdentityServerEmpty.csproj | 1 + identity-server/templates/src/IdentityServerEmpty/Program.cs | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/identity-server/templates/src/IdentityServerEmpty/Config.cs b/identity-server/templates/src/IdentityServerEmpty/Config.cs index d54c74bd9..7af0c5afa 100644 --- a/identity-server/templates/src/IdentityServerEmpty/Config.cs +++ b/identity-server/templates/src/IdentityServerEmpty/Config.cs @@ -1,6 +1,6 @@ using Duende.IdentityServer.Models; -namespace IdentityServerEmpty; +namespace IdentityServerHost; public static class Config { diff --git a/identity-server/templates/src/IdentityServerEmpty/HostingExtensions.cs b/identity-server/templates/src/IdentityServerEmpty/HostingExtensions.cs index 37b64bbac..314272c9a 100644 --- a/identity-server/templates/src/IdentityServerEmpty/HostingExtensions.cs +++ b/identity-server/templates/src/IdentityServerEmpty/HostingExtensions.cs @@ -2,7 +2,7 @@ using System.Globalization; using Serilog; using Serilog.Filters; -namespace IdentityServerEmpty; +namespace IdentityServerHost; internal static class HostingExtensions { diff --git a/identity-server/templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj b/identity-server/templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj index 3263c222c..a2c24c1e4 100644 --- a/identity-server/templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj +++ b/identity-server/templates/src/IdentityServerEmpty/IdentityServerEmpty.csproj @@ -4,6 +4,7 @@ net10.0 enable enable + IdentityServerHost diff --git a/identity-server/templates/src/IdentityServerEmpty/Program.cs b/identity-server/templates/src/IdentityServerEmpty/Program.cs index d75f610c8..b2cadb7f8 100644 --- a/identity-server/templates/src/IdentityServerEmpty/Program.cs +++ b/identity-server/templates/src/IdentityServerEmpty/Program.cs @@ -1,7 +1,7 @@ using System.Globalization; using System.Text; using Duende.IdentityServer.Licensing; -using IdentityServerEmpty; +using IdentityServerHost; using Serilog; Log.Logger = new LoggerConfiguration() From 0c65a9863082142781f4eff7dfeb9792c03d0d46 Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:35:31 +0100 Subject: [PATCH 07/11] IdentityServerAspNetIdentity: Set rootnamespace to "IdentityServerHost" and fix namespaces. --- .../IdentityServerAspNetIdentity/Config.cs | 2 +- .../HostingExtensions.cs | 2 +- .../IdentityServerAspNetIdentity.csproj | 36 +++++++++---------- .../Pages/Account/Login/Index.cshtml | 4 +-- .../Pages/Account/Login/Index.cshtml.cs | 2 +- .../Pages/Account/Login/InputModel.cs | 2 +- .../Pages/Account/Login/LoginOptions.cs | 2 +- .../Pages/Account/Login/ViewModel.cs | 2 +- .../Pages/Account/Logout/Index.cshtml | 4 +-- .../Pages/Account/Logout/Index.cshtml.cs | 2 +- .../Pages/Account/Logout/LoggedOut.cshtml | 4 +-- .../Pages/Account/Logout/LoggedOut.cshtml.cs | 2 +- .../Account/Logout/LoggedOutViewModel.cs | 2 +- .../Pages/Account/Logout/LogoutOptions.cs | 2 +- .../Pages/{Home => }/Error/Index.cshtml | 0 .../Pages/{Home => }/Error/Index.cshtml.cs | 2 +- .../Pages/{Home => }/Error/ViewModel.cs | 0 .../Pages/Index.cshtml | 2 +- .../Pages/Index.cshtml.cs | 2 +- .../Pages/_ViewImports.cshtml | 3 +- .../IdentityServerAspNetIdentity/Program.cs | 1 + .../IdentityServerAspNetIdentity/SeedData.cs | 2 +- 22 files changed, 40 insertions(+), 40 deletions(-) rename identity-server/templates/src/IdentityServerAspNetIdentity/Pages/{Home => }/Error/Index.cshtml (100%) rename identity-server/templates/src/IdentityServerAspNetIdentity/Pages/{Home => }/Error/Index.cshtml.cs (94%) rename identity-server/templates/src/IdentityServerAspNetIdentity/Pages/{Home => }/Error/ViewModel.cs (100%) diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Config.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Config.cs index 8afdc0274..731e829e0 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Config.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Config.cs @@ -1,6 +1,6 @@ using Duende.IdentityServer.Models; -namespace IdentityServerAspNetIdentity; +namespace IdentityServerHost; public static class Config { diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/HostingExtensions.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/HostingExtensions.cs index 4170d7f3e..e370452ca 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/HostingExtensions.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/HostingExtensions.cs @@ -8,7 +8,7 @@ using Microsoft.IdentityModel.Tokens; using Serilog; using Serilog.Filters; -namespace IdentityServerAspNetIdentity; +namespace IdentityServerHost; internal static class HostingExtensions { diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/IdentityServerAspNetIdentity.csproj b/identity-server/templates/src/IdentityServerAspNetIdentity/IdentityServerAspNetIdentity.csproj index 6d69b515b..5eb0ffceb 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/IdentityServerAspNetIdentity.csproj +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/IdentityServerAspNetIdentity.csproj @@ -1,22 +1,22 @@  - - net10.0 - enable - enable - + + net10.0 + enable + enable + IdentityServerHost + - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/Index.cshtml b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/Index.cshtml index 1ec5ae3f1..ea6287f49 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/Index.cshtml +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Login.Index +@model IdentityServerHost.Pages.Account.Login.Index -

\ No newline at end of file +

diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/Index.cshtml.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/Index.cshtml.cs index 8f1c3fafa..8d34db79e 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/Index.cshtml.cs @@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; [SecurityHeaders] [AllowAnonymous] diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/InputModel.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/InputModel.cs index 18c4291b5..6feaaa7df 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/InputModel.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/InputModel.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public class InputModel { diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/LoginOptions.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/LoginOptions.cs index 8bbd55222..a2040b7c9 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/LoginOptions.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/LoginOptions.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public static class LoginOptions { diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/ViewModel.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/ViewModel.cs index 3daacc708..dd31fb329 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/ViewModel.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Login/ViewModel.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Login; +namespace IdentityServerHost.Pages.Account.Login; public class ViewModel { diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/Index.cshtml b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/Index.cshtml index 2d8c4beb2..f832f94d6 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/Index.cshtml +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Logout.Index +@model IdentityServerHost.Pages.Account.Logout.Index
@@ -14,4 +14,4 @@
-
\ No newline at end of file + diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/Index.cshtml.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/Index.cshtml.cs index 87f4be583..37425a336 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/Index.cshtml.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; [SecurityHeaders] [AllowAnonymous] diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOut.cshtml b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOut.cshtml index 1169453be..f02a89e5e 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOut.cshtml +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOut.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Logout.LoggedOut +@model IdentityServerHost.Pages.Account.Logout.LoggedOut

@@ -27,4 +27,4 @@ { } -} \ No newline at end of file +} diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOut.cshtml.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOut.cshtml.cs index 1b67b0857..cb308a835 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOut.cshtml.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOut.cshtml.cs @@ -2,7 +2,7 @@ using Duende.IdentityServer.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; [SecurityHeaders] [AllowAnonymous] diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOutViewModel.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOutViewModel.cs index e45de4031..07826af80 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOutViewModel.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LoggedOutViewModel.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; public class LoggedOutViewModel { diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LogoutOptions.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LogoutOptions.cs index f4d08bda0..84ee205ee 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LogoutOptions.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Account/Logout/LogoutOptions.cs @@ -1,4 +1,4 @@ -namespace IdentityServerHost.Pages.Logout; +namespace IdentityServerHost.Pages.Account.Logout; public static class LogoutOptions { diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Home/Error/Index.cshtml b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Error/Index.cshtml similarity index 100% rename from identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Home/Error/Index.cshtml rename to identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Error/Index.cshtml diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Home/Error/Index.cshtml.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Error/Index.cshtml.cs similarity index 94% rename from identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Home/Error/Index.cshtml.cs rename to identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Error/Index.cshtml.cs index 5102cfc93..bf3b8d4c5 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Home/Error/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Error/Index.cshtml.cs @@ -21,7 +21,7 @@ public class Index : PageModel public async Task OnGet(string? errorId) { - // retrieve error details from identityserver + // retrieve error details from IdentityServer var message = await _interaction.GetErrorContextAsync(errorId); if (message != null) { diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Home/Error/ViewModel.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Error/ViewModel.cs similarity index 100% rename from identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Home/Error/ViewModel.cs rename to identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Error/ViewModel.cs diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Index.cshtml b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Index.cshtml index a6e13cbf6..a4c2542a6 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Index.cshtml +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Index.cshtml @@ -1,5 +1,5 @@ @page -@model IdentityServerHost.Pages.Home.Index +@model IdentityServerHost.Pages.Index

diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Index.cshtml.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Index.cshtml.cs index 99a272048..c9c43363d 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Index.cshtml.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/Index.cshtml.cs @@ -3,7 +3,7 @@ using Duende.IdentityServer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; -namespace IdentityServerHost.Pages.Home; +namespace IdentityServerHost.Pages; [AllowAnonymous] public class Index : PageModel diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/_ViewImports.cshtml b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/_ViewImports.cshtml index 7537d10a8..afa82bbf2 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/_ViewImports.cshtml +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Pages/_ViewImports.cshtml @@ -1,2 +1 @@ -@using IdentityServerHost.Pages -@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Program.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Program.cs index 8af148424..31a6c18cc 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Program.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Program.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Text; using Duende.IdentityServer.Licensing; using IdentityServerAspNetIdentity; +using IdentityServerHost; using Serilog; Log.Logger = new LoggerConfiguration() diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/SeedData.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/SeedData.cs index 299666ed9..e1b598021 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/SeedData.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/SeedData.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Serilog; -namespace IdentityServerAspNetIdentity; +namespace IdentityServerHost; public class SeedData { From b7cf736a3702355f02e5939acea0a7824490df8d Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:47:24 +0100 Subject: [PATCH 08/11] Template build program targets net10.0 --- templates/build/Program.cs | 6 +++--- templates/build/build.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/build/Program.cs b/templates/build/Program.cs index 268619b6d..e67467e62 100644 --- a/templates/build/Program.cs +++ b/templates/build/Program.cs @@ -82,10 +82,10 @@ void CopyFile(DirectoryInfo directoryInfo, FileInfo fileInfo) bool TryFindFile(string fileName, [NotNullWhen(true)] out FileInfo? found) { + var executingAssemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + ?? throw new InvalidOperationException("Failed to find executing assembly location"); - - var currentDir = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) - ?? throw new InvalidOperationException("Failed to find directory for current assembly")); + var currentDir = new DirectoryInfo(executingAssemblyLocation); while (currentDir != null && currentDir.Exists) { diff --git a/templates/build/build.csproj b/templates/build/build.csproj index fd4bd08da..ed9781c22 100644 --- a/templates/build/build.csproj +++ b/templates/build/build.csproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 enable enable From 67c1941ba14a21bfb03db6bba0ce5ca5eb5bf51c Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:47:36 +0100 Subject: [PATCH 09/11] Add net10.0 target framework --- templates/templates.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/templates.csproj b/templates/templates.csproj index 4cb3d729c..93bdf1695 100644 --- a/templates/templates.csproj +++ b/templates/templates.csproj @@ -1,7 +1,7 @@ - net8.0;net9.0 + net8.0;net9.0;net10.0 Duende.Templates Templates for Duende Identity Server and Duende BFF dotnet-new;templates;duende;bff; From bcb4049b65f97a26c16129a70b0f82cd9f18fdf6 Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 10:55:07 +0100 Subject: [PATCH 10/11] Add symbol replacement for namespace --- .../.template.config/template.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/identity-server/templates/src/IdentityServerEmpty/.template.config/template.json b/identity-server/templates/src/IdentityServerEmpty/.template.config/template.json index 4b9ca4f87..61e7d3b6d 100644 --- a/identity-server/templates/src/IdentityServerEmpty/.template.config/template.json +++ b/identity-server/templates/src/IdentityServerEmpty/.template.config/template.json @@ -21,5 +21,15 @@ { "path": "IdentityServerEmpty.csproj" } - ] + ], + "symbols": { + "RenameCommonNamespace": { + "datatype": "string", + "displayName": "Fix common host namespace.", + "replaces": "IdentityServerHost", + "type": "derived", + "valueSource": "name", + "valueTransform": "safe_namespace" + } + } } From bc6992d48aed5aca552a58fb56801897765b6bdc Mon Sep 17 00:00:00 2001 From: Damian Hickey <57436+damianh@users.noreply.github.com> Date: Fri, 12 Dec 2025 11:23:22 +0100 Subject: [PATCH 11/11] Remove unused using directive --- .../templates/src/IdentityServerAspNetIdentity/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/identity-server/templates/src/IdentityServerAspNetIdentity/Program.cs b/identity-server/templates/src/IdentityServerAspNetIdentity/Program.cs index 31a6c18cc..86f76f558 100644 --- a/identity-server/templates/src/IdentityServerAspNetIdentity/Program.cs +++ b/identity-server/templates/src/IdentityServerAspNetIdentity/Program.cs @@ -1,7 +1,6 @@ using System.Globalization; using System.Text; using Duende.IdentityServer.Licensing; -using IdentityServerAspNetIdentity; using IdentityServerHost; using Serilog;