Skip to content

Documenting aspnetcore hosting gap analysis progress - #838

Merged
AndreaCuneo merged 2 commits into
masterfrom
copilot/docsmediator-frameworkprogressaspnetcore-hosting-g
Aug 4, 2026
Merged

Documenting aspnetcore hosting gap analysis progress#838
AndreaCuneo merged 2 commits into
masterfrom
copilot/docsmediator-frameworkprogressaspnetcore-hosting-g

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces strict validation and support for the X-Forwarded-Prefix header in the Minimal API host, ensuring that path base forwarding is secure and predictable. It adds an option to enable or disable this feature, updates documentation to reflect the new behavior, and provides comprehensive tests to verify correct handling of valid, invalid, and ambiguous prefixes.

Forwarded Prefix Handling and Validation

  • Added a UseForwardedPrefix option to ArkMinimalApiHostOptions (default: true), allowing the host to accept and strictly validate the X-Forwarded-Prefix header. If enabled, a valid prefix is prepended to PathBase, while malformed or ambiguous values result in a 400 Bad Request before downstream middleware runs. A private method, TryGetForwardedPrefix, implements the validation logic. ([[1]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-17beb4389c729323e36094919ca76aae4e89b338da7a3af5b883a5b3f835b8e9R37-R41), [[2]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-17beb4389c729323e36094919ca76aae4e89b338da7a3af5b883a5b3f835b8e9R113-R133), [[3]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-17beb4389c729323e36094919ca76aae4e89b338da7a3af5b883a5b3f835b8e9R152-R211))

Documentation Updates

  • Updated the host setup and composition guide to document the new UseForwardedPrefix option, describe the validation process, and clarify the order of middleware execution. The documentation now explains how invalid or ambiguous X-Forwarded-Prefix values are handled and how to disable the feature if handled externally. ([[1]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-5c75e2f737b7656e9b1177be1b75d861f5bea87ddde3c539dbf5d94f90a4a9a8R142), [[2]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-5c75e2f737b7656e9b1177be1b75d861f5bea87ddde3c539dbf5d94f90a4a9a8L173-R174), [[3]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-5c75e2f737b7656e9b1177be1b75d861f5bea87ddde3c539dbf5d94f90a4a9a8L192-R196))

Testing

  • Added ForwardedPrefixTests to verify that valid prefixes are accepted, malformed prefixes are rejected, and multiple prefixes are treated as ambiguous and rejected with a 400 status. ([samples/Ark.MediatorFramework.Sample/test/Ark.MediatorFramework.Sample.Tests/ForwardedPrefixTests.csR1-R54](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-0ebd5a9647b64f9062ff6f623f21f897166caa26b9aec9227c9ad64202d0ad3cR1-R54))
  • Updated the progress tracking document to mark the relevant acceptance criteria as completed for forwarded prefix validation and error handling. ([docs/mediator-framework/progress/tasks/aspnetcore/HST-03-path-base-validation.mdL33-R37](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-3a23c981c679cc2d08d43aad13e539de26f887dd5c5604bc03ad56ce0b23fb5dL33-R37))Pull request created by AI Agent

Copilot AI and others added 2 commits August 4, 2026 16:34
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
@AndreaCuneo
AndreaCuneo marked this pull request as ready for review August 4, 2026 17:23
@AndreaCuneo
AndreaCuneo requested a review from a team as a code owner August 4, 2026 17:23
Copilot AI lite review requested due to automatic review settings August 4, 2026 17:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds strict X-Forwarded-Prefix handling to the Minimal API host pipeline (with an application opt-out) and documents the new behavior as part of the ASP.NET Core hosting gap-analysis progress.

Changes:

  • Add ArkMinimalApiHostOptions.UseForwardedPrefix (default true) and middleware that validates X-Forwarded-Prefix, rejecting malformed/ambiguous values with HTTP 400.
  • Add sample integration tests covering valid/invalid/multiple X-Forwarded-Prefix header scenarios.
  • Update mediator framework docs and task tracking to reflect the new forwarded-prefix validation behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/aspnetcore/Ark.Tools.AspNetCore.MinimalApi/ArkMinimalApiHostExtensions.cs Introduces forwarded-prefix option + request middleware that validates and applies X-Forwarded-Prefix to PathBase.
samples/Ark.MediatorFramework.Sample/test/Ark.MediatorFramework.Sample.Tests/ForwardedPrefixTests.cs Adds integration tests verifying 200 for a valid prefix and 400 for invalid/multiple prefixes.
docs/mediator-framework/progress/tasks/aspnetcore/HST-03-path-base-validation.md Marks the forwarded-prefix validation acceptance items as completed.
docs/mediator-framework/guide/host-setup-and-composition.md Documents forwarded-prefix validation in host setup and middleware ordering guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/mediator-framework/guide/host-setup-and-composition.md
@AndreaCuneo
AndreaCuneo merged commit 48bd7e8 into master Aug 4, 2026
7 checks passed
@AndreaCuneo
AndreaCuneo deleted the copilot/docsmediator-frameworkprogressaspnetcore-hosting-g branch August 4, 2026 17:35
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.

3 participants