Skip to content

Harden operational health and request security defaults - #579

Merged
cdcavell merged 4 commits into
mainfrom
issue_work
Sep 23, 2026
Merged

cdcavell merged 4 commits into
mainfrom
issue_work

Conversation

@cdcavell

Copy link
Copy Markdown
Collaborator

Summary

This change addresses the reviewed operational and security gaps in
NetCoreApplicationTemplate while preserving the existing 2.x architecture and
configuration model.

The updates tighten readiness semantics, improve audit-reconciliation health
reporting, harden rate-limiting behavior, make path-exclusion configuration fully
replaceable, and strengthen the default authentication cookie posture.

Changes

Audit integrity health

  • Added a configurable HealthStaleAfter threshold to audit reconciliation.
  • Treats a missing LastRunUtc as degraded health when reconciliation is enabled.
  • Treats reconciliation as degraded when the last successful run exceeds the
    configured staleness threshold.
  • Includes reconciliation age in health-check diagnostic data.
  • Added focused coverage for the stale / never-run health paths.

Readiness separation

  • Removed application-audit-integrity from the ready health-check tag.
  • Added a dedicated /health/audit-integrity endpoint.
  • Keeps audit-integrity incidents visible to operators without automatically
    removing otherwise serviceable replicas from traffic.

Database readiness

  • Added a database connectivity health check when application data access is
    enabled.
  • Tags the database check with ready, so /health/ready now reflects whether
    the configured application database is reachable.
  • Leaves readiness lightweight when data access is explicitly disabled.

Rate limiting

  • Normalizes native IPv6 client addresses to their /64 network prefix so a
    client cannot obtain fresh buckets merely by rotating interface identifiers.
  • Normalizes IPv4-mapped IPv6 addresses back to IPv4.
  • Partitions the named concurrency policy by client and endpoint rather than
    sharing one limiter across every caller of an endpoint.
  • Added tests covering IPv6 /64 normalization and partition separation.

Configuration binding

  • Explicit ExcludedPathPrefixes configuration for request logging now replaces
    the CLR default list instead of being appended to it.
  • The same replacement behavior now applies to security-header exclusions.
  • This allows consumers to deliberately remove defaults such as /health or
    /metrics.

Authentication cookie hardening

  • Secure authentication sessions now use:

    __Host-ProjectTemplate.Web.Authentication

  • Explicitly sets:

    • Secure
    • Path=/
    • no cookie domain
    • HttpOnly
    • SameSite=Lax
  • The Development-only insecure HTTP override retains the legacy non-__Host-
    cookie name because the __Host- contract requires Secure.

Documentation

Updated health-check, audit-reconciliation, rate-limiting, authentication, and
changelog documentation to describe the new behavior and operational guidance.

Notes

The previously reported SUPPORT.md release-tense issue no longer applies to the
current repository state because 2.10.0 has already been published.

Validation

Recommended validation:

dotnet build --configuration Release
dotnet test --configuration Release
Test run summary: Passed!
  total: 505
  failed: 0
  succeeded: 505
  skipped: 0
  duration: 13s 336ms

Copilot AI lite review requested due to automatic review settings September 23, 2026 19:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical database readiness, route/configuration contract, and build-documentation issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 3 High severity · 2 Low severity

Open (5)
What changed in this PR

Hardens health checks, rate limiting, configuration binding, authentication cookies, tests, and operational documentation.

Changes:

  • Adds database readiness and audit-integrity health behavior.
  • Normalizes rate-limit client partitions.
  • Makes path exclusions replaceable.
  • Strengthens authentication cookie defaults.
  • Updates tests, documentation, and template defaults.
File Description
tests/​ProjectTemplate.Web.Tests/​RateLimitingTests.cs Tests client partitioning behavior.
tests/​ProjectTemplate.Web.Tests/​Infrastructure/​ApplicationWebApplicationFactory.cs Configures test health defaults.
tests/​ProjectTemplate.Web.Tests/​HealthCheckTests.cs Tests health endpoints.
tests/​ProjectTemplate.Web.Tests/​ConfigurationListBindingTests.cs Tests list replacement semantics.
tests/​ProjectTemplate.Web.Tests/​AuthenticationCookieSecurePolicyTests.cs Tests cookie hardening.
tests/​ProjectTemplate.Web.Tests/​ApplicationAuditIntegrityHealthCheckTests.cs Tests audit freshness behavior.
src/​ProjectTemplate.Web/​Options/​ConcurrencyRateLimitingOptions.cs Adds concurrency partitioning options.
src/​ProjectTemplate.Web/​Options/​ApplicationSecurityHeadersOptions.cs Configures security exclusions.
src/​ProjectTemplate.Web/​Options/​ApplicationRequestLoggingOptions.cs Configures logging exclusions.
src/​ProjectTemplate.Web/​Options/​ApplicationRateLimitingOptions.cs Adds IPv6 prefix options.
src/​ProjectTemplate.Web/​Options/​ApplicationHealthCheckOptions.cs Adds health-check options.
src/​ProjectTemplate.Web/​HealthChecks/​ApplicationHealthCheckTags.cs Defines health tags.
src/​ProjectTemplate.Web/​HealthChecks/​ApplicationDatabaseHealthCheck.cs Checks database connectivity.
src/​ProjectTemplate.Web/​HealthChecks/​ApplicationAuditIntegrityHealthCheck.cs Evaluates audit freshness.
src/​ProjectTemplate.Web/​Extensions/​StartupSecurityPostureExtensions.cs Updates health-route diagnostics.
src/​ProjectTemplate.Web/​Extensions/​SecurityHeadersExtensions.cs Applies exclusion binding.
src/​ProjectTemplate.Web/​Extensions/​RequestLoggingExtensions.cs Applies exclusion binding.
src/​ProjectTemplate.Web/​Extensions/​RateLimitingServiceExtensions.cs Implements client partitions.
src/​ProjectTemplate.Web/​Extensions/​HealthCheckExtensions.cs Maps health endpoints and tags.
src/​ProjectTemplate.Web/​Extensions/​DataAccessServiceExtensions.cs Registers database checks.
src/​ProjectTemplate.Web/​Extensions/​ConfigurationListBinding.cs Implements list replacement.
src/​ProjectTemplate.Web/​Extensions/​ApplicationAuditReconciliationServiceExtensions.cs Separates audit readiness.
src/​ProjectTemplate.Web/​Authentication/​Extensions/​AuthenticationServiceExtensions.cs Hardens authentication cookies.
src/​ProjectTemplate.Web/​appsettings.json Adds operational defaults.
src/​ProjectTemplate.Infrastructure/​Data/​Extensions/​ApplicationAuditReconciliationServiceExtensions.cs Validates audit thresholds.
src/​ProjectTemplate.Infrastructure/​Data/​Auditing/​ApplicationAuditReconciliationContracts.cs Adds stale-run configuration.
docs/​articles/​security-headers.md Documents exclusion behavior.
docs/​articles/​rate-limiting.md Documents client partitioning.
docs/​articles/​health-checks.md Documents health behavior.
docs/​articles/​authentication.md Documents cookie hardening.
docs/​articles/​audit-reconciliation.md Documents audit freshness.
CHANGELOG.md Records behavior changes.
.template.content/​src/​ProjectTemplate.Web/​appsettings.json Updates template defaults.
.github/​SUPPORT.md Contains support lifecycle wording.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/articles/health-checks.md Outdated
Comment thread tests/ProjectTemplate.Web.Tests/RateLimitingTests.cs
Comment thread .github/SUPPORT.md Outdated
Comment thread src/ProjectTemplate.Web/Extensions/HealthCheckExtensions.cs Outdated
Copilot AI review requested due to automatic review settings September 23, 2026 19:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved release wording, reload binding, SQLite readiness, and test documentation issues remain.

Review effort: Lite
Findings: 3 High severity · 2 Low severity

Open (5)
Previously missed (1)

In code that hasn't changed since last review

Low severity Align changelog entry with the corrected 2.10.0 release status

CHANGELOG.md:126

This entry says .github/SUPPORT.md was corrected because the 2.10.0 release-tense issue was fixed, but the accompanying SUPPORT diff reintroduces the upcoming 2.10.0/latest 2.9.0 wording. Once the release status is reconciled, update or remove this changelog entry so it describes the actual change.

Copilot AI review requested due to automatic review settings September 23, 2026 20:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Health endpoint mappings currently break readiness and expose audit health incorrectly.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (5)

Comment thread src/ProjectTemplate.Web/Extensions/HealthCheckExtensions.cs Outdated
The previous commit renamed the readiness mapping instead of the audit
mapping, so /health/ready returned 404, /health/audit-integrity ran the
readiness checks, and audit checks were only served at the undocumented
/health/audit route. Map /health/ready to checks tagged ready, map
/health/audit-integrity to checks tagged audit, and drop /health/audit.

Add a regression test that registers an unhealthy check under each tag
and verifies it affects only the endpoint that selects that tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 23, 2026 23:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved cookie-domain and audit-freshness issues remain, along with a configuration naming inconsistency.

Review effort: Lite
Findings: None

Resolved since last review (1)

@cdcavell
cdcavell merged commit 852e70a into main Sep 23, 2026
18 checks passed
@cdcavell
cdcavell deleted the issue_work branch September 23, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants