ServiceComposer registers its composition endpoints directly in ASP.NET Core’s endpoint routing system. This means the full suite of standard ASP.NET Core authentication and authorization metadata —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ServiceComposer/ServiceComposer.AspNetCore/llms.txt
Use this file to discover all available pages before exploring further.
[Authorize], [AllowAnonymous], policy-based attributes, and custom requirement attributes — works on composition handlers exactly as it does on MVC controllers or Razor Pages. No special ServiceComposer configuration is required.
Applying authorization to a handler
Decorate a handler method with[Authorize] just as you would a controller action:
Multiple handlers with different requirements
When multiple handlers are registered for the same route, their authorization metadata is merged. The most restrictive combination applies. If one handler requires an authenticated user and another requires a specific policy, both requirements must be satisfied:[Authorize] and [Authorize(Policy = "WarehouseStaff")] are collected from the respective handlers and applied to the /product/{id} route. A caller must be authenticated and belong to the WarehouseStaff policy to reach either handler.
Middleware setup
Add the standard ASP.NET Core authentication and authorization middleware beforeMapCompositionHandlers():
How metadata merging works
WhenMapCompositionHandlers() is called, ServiceComposer inspects every handler registered for each route template and collects all endpoint metadata attributes — [Authorize], [AllowAnonymous], [RequireAuthorization], custom policy attributes, and any other IAuthorizeData or IAllowAnonymous implementation. The collected metadata is merged onto the single composed endpoint that ASP.NET Core registers for that route.
Because authorization is enforced by ASP.NET Core’s standard middleware before composition begins, the request’s
ClaimsPrincipal is fully populated and available on HttpContext.User inside every composition handler that does execute.Common patterns
Requiring authentication on all composed routes
Requiring authentication on all composed routes
Apply a fallback authorization policy globally so that every endpoint — including composed ones — requires authentication unless explicitly opted out:
Opting out of authorization for a specific handler
Opting out of authorization for a specific handler
Resource-based authorization inside a handler
Resource-based authorization inside a handler