From 3786ddf3d5f4cecd0853c417548e90b1ce69b3fa Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 12 Mar 2026 14:08:17 +0800 Subject: [PATCH] fix: copy jwks.json to client output and use ILogger in ServerDataSeedContributor --- .../OpenIddict.Demo.Client.Console.csproj | 9 ++++++--- .../EntityFrameworkCore/ServerDataSeedContributor.cs | 12 +++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/openiddict/app/OpenIddict.Demo.Client.Console/OpenIddict.Demo.Client.Console.csproj b/modules/openiddict/app/OpenIddict.Demo.Client.Console/OpenIddict.Demo.Client.Console.csproj index d2938a216e..cd8ab94121 100644 --- a/modules/openiddict/app/OpenIddict.Demo.Client.Console/OpenIddict.Demo.Client.Console.csproj +++ b/modules/openiddict/app/OpenIddict.Demo.Client.Console/OpenIddict.Demo.Client.Console.csproj @@ -14,12 +14,15 @@ - + PreserveNewest + + PreserveNewest + diff --git a/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs b/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs index ae6687a883..71018b7744 100644 --- a/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs +++ b/modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs @@ -1,4 +1,6 @@ using System.Globalization; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Microsoft.IdentityModel.Tokens; using OpenIddict.Abstractions; using OpenIddict.Demo.Server.ExtensionGrants; @@ -14,6 +16,8 @@ public class ServerDataSeedContributor : IDataSeedContributor, ITransientDepende private readonly IOpenIddictApplicationManager _applicationManager; private readonly IOpenIddictScopeManager _scopeManager; + public ILogger Logger { get; set; } + public ServerDataSeedContributor( ICurrentTenant currentTenant, IOpenIddictApplicationManager applicationManager, @@ -22,6 +26,7 @@ public class ServerDataSeedContributor : IDataSeedContributor, ITransientDepende _currentTenant = currentTenant; _applicationManager = applicationManager; _scopeManager = scopeManager; + Logger = NullLogger.Instance; } public async Task SeedAsync(DataSeedContext context) @@ -169,10 +174,11 @@ public class ServerDataSeedContributor : IDataSeedContributor, ITransientDepende var jwksPath = Path.Combine(AppContext.BaseDirectory, "jwks.json"); if (!File.Exists(jwksPath)) { - Console.WriteLine( - $"[OpenIddict] WARNING: JWKS file not found at '{jwksPath}'. " + + Logger.LogWarning( + "JWKS file not found at '{JwksPath}'. " + "Skipping creation of the 'AbpConsoleAppWithJwks' client. " + - "Run 'abp generate-jwks' in the app/ directory to generate the key pair."); + "Run 'abp generate-jwks' in the app/ directory to generate the key pair.", + jwksPath); } else {