Public concept tally export with one-origin CORS
GET /public/concepts/{collection}/tallies returns per-live-subject up, down and
member counts only, anonymous, Cache-Control public max-age=60. CORS policy
ConceptTallies is built from ConceptVotes:AllowedOrigins, GET only, no
credentials, required on this route alone. Production startup refuses an
allowed origin that is not an exact https origin.
Not yet built or tested when committed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
95ac1f84e6
commit
d13b808471
5 changed files with 391 additions and 2 deletions
|
|
@ -91,10 +91,22 @@ public sealed class StartupConfigurationValidator(
|
|||
failures.Add($"ConceptVotes:IPv6PrefixLength must be between 0 and {NetworkPrefix.IPv6Bits}.");
|
||||
}
|
||||
|
||||
if (!conceptVotes.AllowedOrigins.All(IsExactHttpsOrigin))
|
||||
{
|
||||
failures.Add("ConceptVotes:AllowedOrigins entries must each be exactly https://host with no path, wildcard or trailing slash.");
|
||||
}
|
||||
|
||||
if (failures.Count > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Bifrost startup configuration is incomplete: " + string.Join(" ", failures));
|
||||
}
|
||||
}
|
||||
|
||||
// The authority form is the canonical spelling, so a wildcard, path, query, user info, upper-case host or
|
||||
// default port differs from it and is refused.
|
||||
private static bool IsExactHttpsOrigin(string? origin) =>
|
||||
Uri.TryCreate(origin, UriKind.Absolute, out var uri) &&
|
||||
uri.Scheme == Uri.UriSchemeHttps &&
|
||||
string.Equals(uri.GetLeftPart(UriPartial.Authority), origin, StringComparison.Ordinal);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue