Download plugins/dotnet-blazor/skills/configure-auth/SKILL.md from the publisher, or copy the path and open the repository. PlugMCP lists the skill and does not host the file.
Where does configure-auth live?
The publisher keeps it at https://github.com/dotnet/skills.
Which agents can use configure-auth?
Claude, Cursor, and Codex can read a SKILL.md you add from the publisher's repository.
>
license: MIT
name: configure-auth
description: >
Add authentication and authorization to a Blazor Web App, accounting for the app's render mode.
USE WHEN the user needs [Authorize] on pages, AuthorizeView, role or policy-based access,
login/logout Identity pages, or AuthenticationStateProvider.
Also USE WHEN auth state is null after WebAssembly loads, SignInManager throws in an interactive
component, NotAuthorized content never renders in static SSR, or HttpContext.User is null in
an interactive component.
DO NOT USE for general component authoring (see author-component), for prerendering concerns
unrelated to auth (see support-prerendering), or for managing non-auth cascading state
(see coordinate-components).
Configure Auth
Step 1 — Read AGENTS.md
Read AGENTS.md at the workspace root for the project's interactivity mode and scope before making changes.
The App.razor component must use AuthorizeRouteView and conditionally apply the render mode so that pages excluded from interactive routing render statically.
[CascadingParameter]
private Task<AuthenticationState>? AuthState { get; set; }
protected override async Task OnInitializedAsync()
{
if (AuthState is not null)
{
var state = await AuthState;
var isAdmin = state.User.IsInRole("Admin");
}
}
Step 5 — Identity pages must stay static SSR
SignInManager and UserManager use HttpContext internally and throw in interactive components. Identity pages (login, register, manage) must render as static SSR.
In a globally interactive app, mark every Identity page:
This forces a full-page navigation (exits the interactive circuit) so the page renders through the static SSR pipeline with a real HttpContext.
App.razor must use AcceptsInteractiveRouting() (Step 3) to return null for these pages — otherwise the framework still tries to render them interactively.
In a per-page app, Identity pages are static by default (no @rendermode directive), so [ExcludeFromInteractiveRouting] is not needed.
Step 6 — Auth state in WebAssembly / Auto mode
WebAssembly components run in the browser and have no HttpContext. Auth state must be serialized from the server during prerendering and deserialized on the client.
Same as WebAssembly; register in both Program.cs files
Common Mistakes
Mistake
Symptom
Fix
Using HttpContext.User in interactive component
Null or stale claims
Use [CascadingParameter] Task<AuthenticationState>
SignInManager in interactive component
InvalidOperationException
Move to static SSR page with [ExcludeFromInteractiveRouting]
Missing AddAuthenticationStateSerialization
Anonymous user after WASM loads
Add to server Program.cs; add Deserialization to client Program.cs
<NotAuthorized> in static SSR layout
Content never shown
Static SSR uses middleware pipeline; redirect via LoginPath or RedirectToLogin component
Global interactivity without AcceptsInteractiveRouting
Identity pages crash
Add AcceptsInteractiveRouting() check in App.razor (Step 3)
Missing AddCascadingAuthenticationState()
Task<AuthenticationState> is null
Register in Program.cs (Step 2)
How do I install configure-auth?
Download plugins/dotnet-blazor/skills/configure-auth/SKILL.md from the publisher, or copy the path and open the repository. PlugMCP lists the skill and does not host the file.
Where does configure-auth live?
The publisher keeps it at https://github.com/dotnet/skills.
Which agents can use configure-auth?
Claude, Cursor, and Codex can read a SKILL.md you add from the publisher's repository.