Skip to content

[Fusion] Add auth docs#9502

Merged
michaelstaib merged 1 commit intomainfrom
mst/fusion-docs-020426-2
Apr 2, 2026
Merged

[Fusion] Add auth docs#9502
michaelstaib merged 1 commit intomainfrom
mst/fusion-docs-020426-2

Conversation

@michaelstaib
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 2, 2026 20:42
@github-actions github-actions bot added the 📚 documentation This issue is about working on our documentation. label Apr 2, 2026
@michaelstaib michaelstaib changed the title [Fusion] Add authoriaztion docs [Fusion] Add auth docs Apr 2, 2026
@michaelstaib michaelstaib merged commit fab07e9 into main Apr 2, 2026
7 checks passed
@michaelstaib michaelstaib deleted the mst/fusion-docs-020426-2 branch April 2, 2026 20:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Fusion v16 “Authentication and Authorization” documentation to focus on gateway-side authentication and header propagation, while delegating subgraph authorization guidance to framework-specific documentation.

Changes:

  • Reframes the page to emphasize gateway authentication, header propagation, and gateway-to-subgraph trust.
  • Replaces detailed HotChocolate subgraph authorization examples with a brief “Subgraph Authorization” section linking to HotChocolate docs.
  • Removes the “Known Issues” section and simplifies “Next Steps”.

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

Comment on lines +86 to 90
3. **JWT authentication.** Standard ASP.NET Core JWT Bearer setup. Configure `Authority` and `Audience` for your identity provider (Keycloak, Auth0, Azure AD, etc.).
4. **Authorization.** Registers the authorization services.
5. **Fusion gateway.** Registers the gateway with its configuration source.
6. **Middleware order.** `UseHeaderPropagation()` must come before `UseAuthentication()` so that the `Authorization` header is captured for propagation before the auth middleware consumes it. Then `UseAuthentication()` must come before `UseAuthorization()`.

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The middleware-order guidance here is internally inconsistent with the later “Custom Header Injection” example that derives propagated headers from HttpContext.User (which is populated by UseAuthentication()). Authentication middleware does not consume/remove the Authorization header, so UseHeaderPropagation() does not need to run before UseAuthentication() to forward it; if anything, when propagating derived headers from claims it should run after authentication (and before MapGraphQL()). Please adjust the wording (and/or the pipeline snippet) to reflect the correct ordering rationale.

Copilot uses AI. Check for mistakes.
Comment on lines 93 to 99
By default, ASP.NET Core does not require authentication unless you configure a fallback policy. If you want some queries to be accessible without a token (while still validating tokens when present), do not set a restrictive fallback:

```csharp
builder.Services.AddAuthorization(options =>
{
options.FallbackPolicy = null; // Allow anonymous by default
});
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The main JWT setup snippet already calls builder.Services.AddAuthorization(); and this section later shows builder.Services.AddAuthorization(options => ...). If readers copy/paste both, they’ll register authorization twice. Consider folding the fallback-policy configuration into the primary setup snippet (or explicitly framing this snippet as a replacement for the earlier AddAuthorization() call) to avoid confusion.

Copilot uses AI. Check for mistakes.
- **"Something is broken"** -- Check the middleware order section above and ensure `UseHeaderPropagation()` appears before `UseAuthentication()` in the pipeline.
- **"I need to set up subgraph authorization."** The [HotChocolate Authorization docs](/docs/hotchocolate/v16/securing-your-api/authorization) cover field-level authorization, policies, and claims-based access control for HotChocolate subgraphs.
- **"I need to deploy this securely."** [Deployment & CI/CD](/docs/fusion/v16/deployment-and-ci-cd) covers production deployment patterns including network isolation and CI pipeline setup.
- **"Something is broken."** Check the middleware order section above and ensure `UseHeaderPropagation()` appears before `UseAuthentication()` in the pipeline.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This “Something is broken” troubleshooting bullet repeats the earlier (and potentially incorrect) requirement that UseHeaderPropagation() must appear before UseAuthentication(). Since derived propagated headers (e.g., X-User-Id) require HttpContext.User to be populated, the recommended order should be updated/nuanced (e.g., UseAuthentication() before UseHeaderPropagation() when deriving headers from claims, while raw Authorization forwarding does not require a strict order).

Suggested change
- **"Something is broken."** Check the middleware order section above and ensure `UseHeaderPropagation()` appears before `UseAuthentication()` in the pipeline.
- **"Something is broken."** Check the middleware order section above and verify the order matches your propagation strategy: for raw header forwarding such as `Authorization`, there is no strict requirement that `UseHeaderPropagation()` run before `UseAuthentication()`, but for propagated headers derived from authenticated user claims, `UseAuthentication()` must run before `UseHeaderPropagation()` so `HttpContext.User` is populated.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants