Skip to content

Commit 3786ddf

Browse files
committed
fix: copy jwks.json to client output and use ILogger in ServerDataSeedContributor
1 parent a682d81 commit 3786ddf

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

modules/openiddict/app/OpenIddict.Demo.Client.Console/OpenIddict.Demo.Client.Console.csproj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<!-- jwks-private.pem is the private key for the AbpConsoleAppWithJwks client, used to sign JWT client assertions.
18-
The corresponding public key (jwks.json) is registered on the server side (OpenIddict.Demo.Server).
19-
Both files originate from the parent app/ directory. -->
17+
<!-- jwks-private.pem and jwks.json are generated by 'abp generate-jwks' in the parent app/ directory.
18+
jwks-private.pem: private key used to sign client assertion JWTs.
19+
jwks.json: public JWKS used to read the kid claim and stay in sync with the server-registered key. -->
2020
<None Include="..\jwks-private.pem" Condition="Exists('..\jwks-private.pem')">
2121
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2222
</None>
23+
<None Include="..\jwks.json" Condition="Exists('..\jwks.json')">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</None>
2326
</ItemGroup>
2427

2528
</Project>

modules/openiddict/app/OpenIddict.Demo.Server/EntityFrameworkCore/ServerDataSeedContributor.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System.Globalization;
2+
using Microsoft.Extensions.Logging;
3+
using Microsoft.Extensions.Logging.Abstractions;
24
using Microsoft.IdentityModel.Tokens;
35
using OpenIddict.Abstractions;
46
using OpenIddict.Demo.Server.ExtensionGrants;
@@ -14,6 +16,8 @@ public class ServerDataSeedContributor : IDataSeedContributor, ITransientDepende
1416
private readonly IOpenIddictApplicationManager _applicationManager;
1517
private readonly IOpenIddictScopeManager _scopeManager;
1618

19+
public ILogger<ServerDataSeedContributor> Logger { get; set; }
20+
1721
public ServerDataSeedContributor(
1822
ICurrentTenant currentTenant,
1923
IOpenIddictApplicationManager applicationManager,
@@ -22,6 +26,7 @@ public ServerDataSeedContributor(
2226
_currentTenant = currentTenant;
2327
_applicationManager = applicationManager;
2428
_scopeManager = scopeManager;
29+
Logger = NullLogger<ServerDataSeedContributor>.Instance;
2530
}
2631

2732
public async Task SeedAsync(DataSeedContext context)
@@ -169,10 +174,11 @@ await _applicationManager.CreateAsync(new OpenIddictApplicationDescriptor
169174
var jwksPath = Path.Combine(AppContext.BaseDirectory, "jwks.json");
170175
if (!File.Exists(jwksPath))
171176
{
172-
Console.WriteLine(
173-
$"[OpenIddict] WARNING: JWKS file not found at '{jwksPath}'. " +
177+
Logger.LogWarning(
178+
"JWKS file not found at '{JwksPath}'. " +
174179
"Skipping creation of the 'AbpConsoleAppWithJwks' client. " +
175-
"Run 'abp generate-jwks' in the app/ directory to generate the key pair.");
180+
"Run 'abp generate-jwks' in the app/ directory to generate the key pair.",
181+
jwksPath);
176182
}
177183
else
178184
{

0 commit comments

Comments
 (0)