From 2551c561cd7d0f689305e43c3194a734dbc9f92a Mon Sep 17 00:00:00 2001 From: Diana Barros Date: Mon, 2 Dec 2024 22:31:52 +0000 Subject: [PATCH] Replace IdentityServer4 with Duende.IdentityServer (#3008) --- test/WebSites/OAuth2Integration/AuthServer/Config.cs | 4 ++-- .../AuthServer/Controllers/AccountController.cs | 2 +- .../AuthServer/Controllers/ConsentController.cs | 8 +------- test/WebSites/OAuth2Integration/Startup.cs | 1 + 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/test/WebSites/OAuth2Integration/AuthServer/Config.cs b/test/WebSites/OAuth2Integration/AuthServer/Config.cs index 6a7c64a610..368cb8e820 100644 --- a/test/WebSites/OAuth2Integration/AuthServer/Config.cs +++ b/test/WebSites/OAuth2Integration/AuthServer/Config.cs @@ -4,9 +4,9 @@ namespace OAuth2Integration.AuthServer { - internal static class Config + public static class Config { - public static IEnumerable Clients() + internal static IEnumerable Clients() { yield return new Client { diff --git a/test/WebSites/OAuth2Integration/AuthServer/Controllers/AccountController.cs b/test/WebSites/OAuth2Integration/AuthServer/Controllers/AccountController.cs index ba4d65bf30..39a97b6f3b 100644 --- a/test/WebSites/OAuth2Integration/AuthServer/Controllers/AccountController.cs +++ b/test/WebSites/OAuth2Integration/AuthServer/Controllers/AccountController.cs @@ -35,9 +35,9 @@ public async Task Login([FromForm] LoginViewModel viewModel) return View("/AuthServer/Views/Login.cshtml", viewModel); } + // Use an IdentityServer-compatible ClaimsPrincipal var identityServerUser = new IdentityServerUser(viewModel.Username); identityServerUser.DisplayName = viewModel.Username; - await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, identityServerUser.CreatePrincipal()); return Redirect(viewModel.ReturnUrl); diff --git a/test/WebSites/OAuth2Integration/AuthServer/Controllers/ConsentController.cs b/test/WebSites/OAuth2Integration/AuthServer/Controllers/ConsentController.cs index 704d54839b..0d977b42a5 100644 --- a/test/WebSites/OAuth2Integration/AuthServer/Controllers/ConsentController.cs +++ b/test/WebSites/OAuth2Integration/AuthServer/Controllers/ConsentController.cs @@ -12,17 +12,11 @@ namespace OAuth2Integration.AuthServer.Controllers public class ConsentController : Controller { private readonly IIdentityServerInteractionService _interaction; - private readonly IClientStore _clientStore; - private readonly IResourceStore _resourceStore; public ConsentController( - IIdentityServerInteractionService interaction, - IClientStore clientStore, - IResourceStore resourceStore) + IIdentityServerInteractionService interaction) { _interaction = interaction; - _clientStore = clientStore; - _resourceStore = resourceStore; } [HttpGet("consent")] diff --git a/test/WebSites/OAuth2Integration/Startup.cs b/test/WebSites/OAuth2Integration/Startup.cs index 9c95576940..78053a6526 100644 --- a/test/WebSites/OAuth2Integration/Startup.cs +++ b/test/WebSites/OAuth2Integration/Startup.cs @@ -63,6 +63,7 @@ public void ConfigureServices(IServiceCollection services) { c.SwaggerDoc("v1", new OpenApiInfo { Version = "v1", Title = "Test API V1" }); + // Define the OAuth2.0 scheme that's in use (i.e. Implicit Flow) c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme { Type = SecuritySchemeType.OAuth2,