- .NET 8 LTS solution with 7 projects (domain/application/infrastructure/api/shared/pos.core/pos[WPF]) - Central package management (Directory.Packages.props), .editorconfig, global.json pin to 8.0.417 - PostgreSQL 14 dev DB via existing brew service; food_market database created - ASP.NET Identity + OpenIddict 5 (password + refresh token flows) with ephemeral dev keys - EF Core 8 + Npgsql; multi-tenant query filter via reflection over ITenantEntity - Initial migration: 13 tables (Identity + OpenIddict + organizations) - AuthorizationController implements /connect/token; seeders create demo org + admin - Protected /api/me endpoint returns current user + org claims - React 19 + Vite 8 + Tailwind v4 SPA with TanStack Query, React Router 7 - Login flow with dev-admin placeholder, bearer interceptor + refresh token fallback - docs/architecture.md, CLAUDE.md, README.md Verified end-to-end: health check, password grant issues JWT with org_id, web app builds successfully (310 kB gzipped). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
66 lines
2.2 KiB
C#
66 lines
2.2 KiB
C#
using OpenIddict.Abstractions;
|
|
using static OpenIddict.Abstractions.OpenIddictConstants;
|
|
|
|
namespace foodmarket.Api.Seed;
|
|
|
|
public class OpenIddictClientSeeder : IHostedService
|
|
{
|
|
public const string WebClientId = "food-market-web";
|
|
public const string PosClientId = "food-market-pos";
|
|
|
|
private readonly IServiceProvider _services;
|
|
|
|
public OpenIddictClientSeeder(IServiceProvider services)
|
|
{
|
|
_services = services;
|
|
}
|
|
|
|
public async Task StartAsync(CancellationToken ct)
|
|
{
|
|
using var scope = _services.CreateScope();
|
|
var mgr = scope.ServiceProvider.GetRequiredService<IOpenIddictApplicationManager>();
|
|
|
|
if (await mgr.FindByClientIdAsync(WebClientId, ct) is null)
|
|
{
|
|
await mgr.CreateAsync(new OpenIddictApplicationDescriptor
|
|
{
|
|
ClientId = WebClientId,
|
|
DisplayName = "food-market web admin",
|
|
ClientType = ClientTypes.Public,
|
|
Permissions =
|
|
{
|
|
Permissions.Endpoints.Token,
|
|
Permissions.GrantTypes.Password,
|
|
Permissions.GrantTypes.RefreshToken,
|
|
Permissions.Scopes.Email,
|
|
Permissions.Scopes.Profile,
|
|
Permissions.Scopes.Roles,
|
|
Permissions.Prefixes.Scope + "api",
|
|
}
|
|
}, ct);
|
|
}
|
|
|
|
if (await mgr.FindByClientIdAsync(PosClientId, ct) is null)
|
|
{
|
|
await mgr.CreateAsync(new OpenIddictApplicationDescriptor
|
|
{
|
|
ClientId = PosClientId,
|
|
DisplayName = "food-market POS client",
|
|
ClientType = ClientTypes.Public,
|
|
Permissions =
|
|
{
|
|
Permissions.Endpoints.Token,
|
|
Permissions.GrantTypes.Password,
|
|
Permissions.GrantTypes.RefreshToken,
|
|
Permissions.Scopes.Email,
|
|
Permissions.Scopes.Profile,
|
|
Permissions.Scopes.Roles,
|
|
Permissions.Prefixes.Scope + "api",
|
|
}
|
|
}, ct);
|
|
}
|
|
}
|
|
|
|
public Task StopAsync(CancellationToken ct) => Task.CompletedTask;
|
|
}
|