wip: doctor/cli/docs/api to vector db consolidation; api hardening for descriptions, tenant, and scopes; migrations and conversions of all DALs to EF v10

This commit is contained in:
master
2026-02-23 15:30:50 +02:00
parent bd8fee6ed8
commit e746577380
1424 changed files with 81225 additions and 25251 deletions

View File

@@ -85,21 +85,34 @@ public sealed partial class TenantContextMiddleware
private TenantValidationResult ValidateTenantContext(HttpContext context)
{
// Extract tenant header
// Extract tenant: header first, then canonical claim, then legacy claim fallback.
var tenantHeader = context.Request.Headers[TenantContextConstants.TenantHeader].FirstOrDefault();
// POL-TEN-01: Fall back to canonical stellaops:tenant claim if header is absent.
if (string.IsNullOrWhiteSpace(tenantHeader))
{
tenantHeader = context.User?.FindFirst(TenantContextConstants.CanonicalTenantClaim)?.Value;
}
// POL-TEN-01: Fall back to legacy "tid" claim for backwards compatibility.
if (string.IsNullOrWhiteSpace(tenantHeader))
{
tenantHeader = context.User?.FindFirst(TenantContextConstants.LegacyTenantClaim)?.Value;
}
if (string.IsNullOrWhiteSpace(tenantHeader))
{
if (_options.RequireTenantHeader)
{
_logger.LogWarning(
"Missing required {Header} header for {Path}",
"Missing required tenant context (header {Header} or claim {Claim}) for {Path}",
TenantContextConstants.TenantHeader,
TenantContextConstants.CanonicalTenantClaim,
context.Request.Path);
return TenantValidationResult.Failure(
TenantContextConstants.MissingTenantHeaderErrorCode,
$"The {TenantContextConstants.TenantHeader} header is required.");
$"Tenant context is required. Provide the {TenantContextConstants.TenantHeader} header or a token with the {TenantContextConstants.CanonicalTenantClaim} claim.");
}
// Use default tenant ID when header is not required