Kodevy.Platform.API
4.4.1
dotnet add package Kodevy.Platform.API --version 4.4.1
NuGet\Install-Package Kodevy.Platform.API -Version 4.4.1
<PackageReference Include="Kodevy.Platform.API" Version="4.4.1" />
<PackageVersion Include="Kodevy.Platform.API" Version="4.4.1" />
<PackageReference Include="Kodevy.Platform.API" />
paket add Kodevy.Platform.API --version 4.4.1
#r "nuget: Kodevy.Platform.API, 4.4.1"
#:package Kodevy.Platform.API@4.4.1
#addin nuget:?package=Kodevy.Platform.API&version=4.4.1
#tool nuget:?package=Kodevy.Platform.API&version=4.4.1
Kodevy Platform
Shared .NET 8 libraries for building microservices with Clean Architecture. These packages provide the foundational plumbing so your microservices stay consistent, production-ready, and free of boilerplate.
Packages
| Package | Description |
|---|---|
Kodevy.Platform.API |
API plumbing — middleware, JWT authentication, authorization, Swagger, health checks, Serilog integration |
Kodevy.Platform.Application |
Application layer primitives — API clients, configuration, current user service, request/response wrappers |
Kodevy.Platform.Domain |
Domain abstractions — auditable entity interfaces and base types |
Kodevy.Platform.Infra |
Infrastructure components — EF Core extensions (SQL Server, PostgreSQL, MySQL), database providers, Serilog sinks |
Installation
dotnet add package Kodevy.Platform.API
dotnet add package Kodevy.Platform.Application
dotnet add package Kodevy.Platform.Domain
dotnet add package Kodevy.Platform.Infra
Install only the layers your project needs. In a Clean Architecture setup:
- API project —
Kodevy.Platform.API - Application project —
Kodevy.Platform.Application - Domain project —
Kodevy.Platform.Domain - Infrastructure project —
Kodevy.Platform.Infra
What's Included
Kodevy.Platform.API
- Global exception handling middleware
- Request context middleware
- JWT authentication strategy (configurable)
- Claims-based authorization strategy
ToHttpResultmapping that returns consistent API envelope metadata (statusCode,path,timestamp, and developmentstackTrace)- API versioning via URL segment (
/api/v{version}/...) - Swagger / OpenAPI configuration with per-version documents and JWT bearer support
- Health check extensions (including EF Core database checks)
- Serilog integration, including
GET /api/v1/logs(host grants access viaAddPlatformLogsAccess) - Optional OpenTelemetry wiring (traces + metrics, OTLP/console exporters)
- Reusable OAuth options validation and tenant-role authorization filter primitives
Kodevy.Platform.Application
ApiClientBase— typed HTTP client with built-in auth token handlingApiResult/ServiceResponseWrapper/PaginatedResponseWrapper— standard response wrappersICurrentUserService— access to current authenticated user context (UserId,Email,SessionId,Roles)GetRequiredUserId()— helper extension for strict user-id retrievalIUnitOfWork— persistence contractBaseApplicationSettings/AuthConfiguration/JwtSettings/OAuthSettings/OpenTelemetrySettings— configuration modelsOAuthStateCodec— signed OAuth state payload helperOAuthRedirectGuard/OAuthRedirectSettings— strict redirect allowlist guard for OAuth callbacksITenantContextAccessor/ITenantMembershipAuthorizationService— tenant role authorization extension pointsIApplicationLogQuery/ApplicationLogEntryDto— log query contract and DTOs
Kodevy.Platform.Domain
IAuditableEntity— interface for entities with created/modified tracking
Kodevy.Platform.Infra
DatabaseConnection/DatabaseProvider— multi-provider database setup (SQL Server, PostgreSQL, MySQL)AddDatabaseConfiguration/DatabaseConfigurationValidator— bind + validateDatabaseConfigurationonce (database optional; logging connection required whenEnableLoggingis true)AuditSaveChangesInterceptor— automatic audit field population on saveRelationalDatabaseExtensions— EF Core registration with environment-based migration behavior- Serilog database sinks (SQL Server, PostgreSQL) and
ApplicationLogQueryto read recent rows from the sink table
Configuration
Authentication & Authorization
Configure in appsettings.json:
{
"AuthConfiguration": {
"AuthenticationStrategy": "Jwt",
"AuthorizationStrategy": "Claims"
},
"JwtSettings": {
"Secret": "your-secret-key",
"Issuer": "your-issuer",
"Audience": "your-audience",
"SigningAlgorithm": "HS256",
"Authority": "",
"JwksUri": "",
"RequireHttpsMetadata": true,
"RefreshOnIssuerKeyNotFound": true,
"ValidAlgorithms": [],
"PrivateKeyPem": "",
"KeyId": "identity-key-1"
}
}
Compatibility notes:
- Existing HS256 consumers continue to work with
SigningAlgorithm: HS256(default). - For RS256, set
SigningAlgorithm: RS256and configure eitherAuthorityorJwksUri. - Services validate tokens locally using cached signing keys; no per-request network call is required.
- JWT claim names are left as issued (
roles,sub,email). Inbound WS-* rewriting is disabled (MapInboundClaims = false) soRequireRoleworks for Kodevy services and other backends that consume the same tokens. ICurrentUserServicereads both issued names and mapped WS-* URIs (sub/NameIdentifier,roles/ClaimTypes.Role,email/ClaimTypes.Email).
HS256 mode requirements:
SigningAlgorithm = HS256(or omitted, default)Secret(minimum 32 chars),Issuer,Audience
RS256 mode requirements:
SigningAlgorithm = RS256Issuer,Audience- one of
AuthorityorJwksUri Secretis not required in RS256 mode
Token issuer extras (for auth/identity services):
PrivateKeyPem- RS256 private key (PEM) used for signingKeyId- JWKS key identifier (kid) published with issued tokens
API Versioning (URL Segment)
In your API project startup:
builder.Services.AddControllers();
builder.Services.AddSwaggerConfiguration();
app.UseSwaggerConfiguration();
app.MapControllers();
Controller convention (template standard):
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public sealed class WeatherController : ControllerBase
{
}
Kodevy.Platform.API configures:
- URL segment version reader (
/api/v1/...) - default API version fallback to
1.0when unspecified - one Swagger document per API version at
/swagger/{groupName}/swagger.json
Database
{
"DatabaseConfiguration": {
"Provider": "PostgreSql",
"ConnectionString": "Host=localhost;Database=mydb;Username=user;Password=pass",
"EnableLogging": false,
"LoggingConnectionString": ""
}
}
Supported providers: SqlServer, PostgreSql, MySql
When EnableLogging is true and LoggingConnectionString is set, Serilog writes Information+ events to:
- PostgreSQL table
logs(message,level,timestamp,exception,properties,service) - SQL Server table
dbo.Logs(default Serilog columns)
AddBaseConfiguration() binds and validates this section. Hosts do not need to call AddOptions<DatabaseConfiguration>() again.
Validation:
- omitting the section (or leaving
ProviderandConnectionStringempty) is allowed — for services with no database - when
Provideris set,ConnectionStringis required - when
EnableLoggingistrue,LoggingConnectionStringis required (MySQL logging is not supported)
Application logs API
Every service that calls AddApiPlumbing() and AddBaseAuthenticationAuthorization() exposes:
GET /api/v1/logs?level=Error&search=todoist&from=2026-08-17T00:00:00Z&to=2026-08-17T23:59:59Z&limit=50
The endpoint always uses Platform policy platform_logs. Platform registers that policy as deny-all. The host replaces it with the roles that may read logs:
options.AddPlatformLogsAccess(Roles.SuperAdmin);
A non-Kodevy host passes whatever privileged role it uses (Admin, ops, …). If the host never calls AddPlatformLogsAccess, every request to /logs returns 403.
- Reads from
LoggingConnectionStringwhen set, otherwiseConnectionString - Returns an empty list (not an error) when logging is off or the table has not been created yet
- Default
limitis 50; maximum is 200
OpenTelemetry (Optional)
Platform can bootstrap OpenTelemetry via AddBaseOpenTelemetry() when OpenTelemetry:Enabled is true. It supports:
- ASP.NET Core tracing/metrics instrumentation
- Outbound HTTP client instrumentation
- Runtime metrics
- OTLP exporter and/or console exporter
Configuration behavior:
- If the
OpenTelemetrysection is omitted,Enableddefaults tofalseand no OpenTelemetry pipeline is registered (safe for local dev and services that do not need tracing yet). - To disable explicitly, set
"Enabled": falseinappsettingsor environment-specific overrides. - Do not set
"OtlpEndpoint": "". Prefer omittingOtlpEndpointuntil you have a real collector URL (e.g.http://localhost:4317or your vendor endpoint). Empty strings were invalid with earlier annotation-based validation; Platform 4.3.1+ validates the URL only when the value is non-empty. - OTLP export in code is still skipped unless both
EnableOtlpExporteris enabled andOtlpEndpointis non-empty (existing wireup).
OAuth Redirect Allowlist (Security)
Use OAuthRedirect config and OAuthRedirectGuard.TryBuildSafeRedirect(...) in OAuth callback flows to prevent open-redirect vulnerabilities.
Security defaults:
- absolute redirects are denied unless origin is in
AllowedOrigins - only
http/httpsschemes are considered - path must match
AllowedPathPrefixeswhen configured
Migration behavior:
- Development — migrations are automatically applied on startup
- Production — migrations are not applied automatically. Set
RUN_MIGRATIONS_ONLY=trueto apply migrations and exit
Used By
These packages are consumed by microservices generated with the Kodevy Microservice Templates:
dotnet new install Kodevy.Templates.Microservice.Init
dotnet new kodevy-microservice-init \
--organization Contoso \
--system Platform \
--microservice Identity
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Kodevy.Platform.Application (>= 4.4.1)
- Kodevy.Platform.Infra (>= 4.4.1)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.8)
- Microsoft.AspNetCore.Mvc.Versioning (>= 5.1.0)
- Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer (>= 5.1.0)
- Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (>= 8.0.0)
- Microsoft.Extensions.Http.Resilience (>= 8.8.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.1.1)
- Microsoft.IdentityModel.Protocols (>= 8.1.1)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.1.1)
- Microsoft.OpenApi (>= 1.6.14)
- OpenTelemetry.Exporter.Console (>= 1.12.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.12.0)
- OpenTelemetry.Extensions.Hosting (>= 1.12.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.12.0)
- OpenTelemetry.Instrumentation.Http (>= 1.12.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.12.0)
- Serilog (>= 4.3.0)
- Serilog.AspNetCore (>= 8.0.0)
- Swashbuckle.AspNetCore (>= 6.5.0)
- System.IdentityModel.Tokens.Jwt (>= 8.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.4.1 | 103 | 8/18/2026 |
| 4.4.0 | 96 | 8/18/2026 |
| 4.3.1 | 151 | 4/6/2026 |
| 4.3.0 | 117 | 3/22/2026 |
| 4.2.2 | 131 | 3/16/2026 |
| 4.2.1 | 121 | 3/12/2026 |
| 4.2.0 | 110 | 3/12/2026 |
| 4.1.1 | 124 | 3/2/2026 |
| 4.1.0 | 114 | 3/2/2026 |
| 4.0.0 | 116 | 3/1/2026 |
| 3.0.1 | 127 | 2/8/2026 |
| 3.0.0 | 126 | 1/2/2026 |
| 2.1.0 | 180 | 12/26/2025 |
| 2.0.0 | 178 | 12/26/2025 |
| 1.0.0 | 206 | 12/24/2025 |