configure-auth
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-prerenderin
npx skills add dotnet/skills --skill configure-auth --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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. ## Step 2 — Register auth services in Program.cs ```csharp // Program.cs (server project) builder.Services.AddCascadingAuthenticationState(); builder.Services.AddAuthorization(); ``` For ASP.NET Core Identity add the Identity services: ```csharp builder.Services.AddAuthentication(options => { options.DefaultScheme = IdentityConstants.ApplicationScheme; options.DefaultSignInScheme = IdentityConstants.ExternalScheme; }) .AddIdentityCookies(); builder.Services.AddIdentityCore<ApplicationUser>() .AddRoles<IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddSignInManager() .AddDefaultTokenProviders(); ``` ## Step 3 — Wire App.razor for auth and render mode The `App.razor` component must use `AuthorizeRouteView` and conditionally apply the render mode so that pages excluded from interactive routing render statically. ```razor <!DOCTYPE html> <html> <head> <HeadOutlet @rendermode="RenderModeForPage" /> </head> <body> <Routes @rendermode="RenderModeForPage" /> <script src="_framework/blazor.web.js"></script> </body> </htm
- Step 1 — Read AGENTS.md
- Step 2 — Register auth services in Program.cs
- Step 3 — Wire App.razor for auth and render mode
- Step 4 — Protect pages and components
- [Authorize] attribute on pages
- AuthorizeView for conditional UI
- Access auth state in code
- Step 5 — Identity pages must stay static SSR
- Step 6 — Auth state in WebAssembly / Auto mode
- Render Mode × Auth Matrix
- Common Mistakes
What does the configure-auth skill do?
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-prerenderin
How do I install it?
Run `npx skills add dotnet/skills --skill configure-auth --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From dotnet/skills, a repository with 4,927 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
