Skip to content

Update .NET 11 Blazor Identity scaffolding - #3836

Merged
haileymck merged 49 commits into
mainfrom
fix/3797-update-blazor-identity
Sep 25, 2026
Merged

haileymck merged 49 commits into
mainfrom
fix/3797-update-blazor-identity

Conversation

@danroth27

@danroth27 danroth27 commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Align the .NET 11 Blazor Identity scaffolder with the Blazor Web App Individual-auth template for static SSR, Server, WebAssembly, and Auto render modes, including passkey metadata, TempData, antiforgery handling, and asynchronous form validation.
  • Preserve normal per-file overwrite behavior, including replacement of PasskeySubmit.razor.js with --overwrite.
  • Configure server and WebAssembly authentication services, routing, navigation, imports, and static Identity-page routing in the appropriate project.
  • Resolve the WebAssembly client through evaluated MSBuild project references and the Blazor WebAssembly SDK marker; fail validation before changing application files when discovery or analysis fails.
  • Share repeated navigation and render-mode text fragments without introducing recipe inheritance or new framework-selection infrastructure.
  • Align the Identity templates with dotnet/aspnetcore release/11.0 commit 5a0e9e1e9a865e8f79fde9cc63bb739f3547c06b.

Coverage retained

  • Static SSR and Blazor Server generation, service registration, and post-scaffolding builds.
  • Global Auto and WebAssembly server/client wiring across .NET 9-11, including routing, navigation, antiforgery differences, and AcceptsInteractiveRouting().
  • Per-page Auto with a custom client namespace, alternate SDK declaration syntax, and split client host startup; all three client authentication registrations must precede builder.Build().
  • Overwrite continuation, stale static-file replacement, navigation idempotence, and compatibility with navigation markup retained by apps upgraded from .NET 10.
  • Missing or ambiguous client projects, restore/analysis failures, evaluated project references, and invalid shared-fragment configurations.

Scope and known limitations

Local validation

  • At 00686ef1, 327 selected Identity and affected-helper tests plus 3 MSBuild project-discovery tests passed.
  • A one-off real-template matrix covered all seven render-mode configurations on .NET 9, 10, and 11. All 21 passed generated-code checks, zero-warning builds, and HTTP checks for Home, Login, and Register after correcting the .NET 11 smoke-check expectation and retrying three .NET 9 cases through the integration-test CLI invocation.
  • The initial direct-DLL runs of those three .NET 9 cases encountered the known Microsoft.Extensions compatibility issue tracked in Restrict scaffolder discovery to dotnet-scaffold #3833; successful retries do not remove that caveat.
  • The final matrix used HTTP smoke checks, not browser-driven registration/login/logout flows.

CI

Linux jobs have repeatedly exhausted hosted-agent disk space during packaging. Disk-capacity investigation is separate from this PR; this PR does not change pipeline configuration. See the current PR checks for the latest job results.

Closes #3797

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.

🔵 Needs a closer look

It spans authentication behavior, generated Identity templates, antiforgery flows, and multiple Blazor render modes across server and client projects.

Pull request overview

Updates .NET 11 Blazor Identity scaffolding to match the Blazor Web App template, including antiforgery, TempData, passkey, validation, email, and render-mode support.

Changes:

  • Refreshes Identity templates and generated T4 outputs.
  • Adds passkey authenticator metadata and improved form handling.
  • Adds server/client authentication wiring, overwrite behavior, and integration coverage.
File summaries
File Description
test/.../ScaffoldCliHelper.cs Updates Blazor navigation test structure.
test/.../Net11TemplateExistenceTests.cs Verifies the new authenticator template.
test/.../AddFileStepTests.cs Tests overwrite and existing-file behavior.
src/.../dotnet-scaffold.csproj Registers the new T4 template outputs.
src/.../PasskeySubmit.razor.js Removes manual antiforgery headers.
src/.../blazorIdentityChanges.json Adds render-mode and Identity code modifications.
src/.../StatusMessage.tt Simplifies status message rendering.
src/.../StatusMessage.cs Regenerates status message output.
src/.../RedirectToLogin.tt Removes obsolete namespace usage.
src/.../RedirectToLogin.cs Regenerates redirect output.
src/.../PasskeySubmit.tt Adds formnovalidate and removes token plumbing.
src/.../PasskeySubmit.cs Regenerates passkey submit output.
src/.../ExternalLoginPicker.tt Removes redundant antiforgery markup.
src/.../ExternalLoginPicker.cs Regenerates external login output.
src/.../PasskeyAuthenticators.tt Adds authenticator display-name mapping.
src/.../PasskeyAuthenticators.Interfaces.cs Adds template interface metadata.
src/.../PasskeyAuthenticators.cs Adds generated authenticator helper output.
src/.../ResetPassword.tt Updates validation and display metadata.
src/.../ResetPassword.cs Regenerates reset-password output.
src/.../ResendEmailConfirmation.tt Updates validation summary markup.
src/.../ResendEmailConfirmation.cs Regenerates confirmation output.
src/.../Register.tt Updates registration validation and sign-in checks.
src/.../Register.cs Regenerates registration output.
src/.../TwoFactorAuthentication.tt Migrates status messages to TempData.
src/.../SetPassword.tt Migrates status messages and invalid-user handling.
src/.../SetPassword.cs Regenerates set-password output.
src/.../ResetAuthenticator.tt Migrates status messages and antiforgery handling.
src/.../ResetAuthenticator.cs Regenerates authenticator-reset output.
src/.../RenamePasskey.tt Migrates passkey status handling.
src/.../RenamePasskey.cs Regenerates rename-passkey output.
src/.../PersonalData.tt Updates TempData and download form handling.
src/.../PersonalData.cs Regenerates personal-data output.
src/.../Passkeys.tt Adds authenticator names, dates, and TempData.
src/.../Index.tt Migrates profile status messages.
src/.../Index.cs Regenerates profile output.
src/.../GenerateRecoveryCodes.tt Migrates recovery-code handling.
src/.../GenerateRecoveryCodes.cs Regenerates recovery-code output.
src/.../ExternalLogins.tt Migrates external-login status handling.
src/.../EnableAuthenticator.tt Updates validation and TempData handling.
src/.../EnableAuthenticator.cs Regenerates authenticator output.
src/.../Email.tt Updates email form metadata and status handling.
src/.../Disable2fa.tt Migrates two-factor status handling.
src/.../Disable2fa.cs Regenerates two-factor output.
src/.../DeletePersonalData.tt Updates validation and TempData handling.
src/.../DeletePersonalData.cs Regenerates deletion output.
src/.../ChangePassword.tt Updates password form metadata and status handling.
src/.../LoginWithRecoveryCode.tt Updates validation summary markup.
src/.../LoginWithRecoveryCode.cs Regenerates recovery-login output.
src/.../LoginWith2fa.tt Updates validation and checkbox markup.
src/.../LoginWith2fa.cs Regenerates two-factor login output.
src/.../Login.tt Uses asynchronous validation and display metadata.
src/.../InvalidUser.tt Generates invalid-user messages directly.
src/.../InvalidUser.cs Regenerates invalid-user output.
src/.../ForgotPassword.tt Updates validation and display metadata.
src/.../ForgotPassword.cs Regenerates forgot-password output.
src/.../ExternalLogin.tt Migrates external-login status handling.
src/.../ConfirmEmailChange.tt Migrates confirmation status handling.
src/.../ConfirmEmailChange.cs Regenerates confirmation output.
src/.../IdentityRedirectManager.tt Replaces cookie status flow with TempData support.
src/.../IdentityRedirectManager.cs Regenerates redirect-manager output.
src/.../IdentityNoOpEmailSender.tt Updates confirmation and reset wording.
src/.../IdentityNoOpEmailSender.cs Regenerates email-sender output.
src/.../IdentityComponentsEndpointRouteBuilderExtensions.tt Adds endpoint antiforgery validation.
src/.../ValidateIdentityStep.cs Detects existing Identity and render modes.
src/.../AddFileStep.cs Adds configurable overwrite behavior.
src/.../BlazorIdentityHelper.cs Adds client-project routing and template filtering.
src/.../ScaffolderBuilderAspNetExtensions.cs Skips dependent steps when already configured.
src/.../BlazorIdentityScaffolderBuilderExtensions.cs Adds client wiring, packages, and overwrite support.
src/.../AspNetCommandService.cs Registers the new client scaffolding steps.
Review details
  • Files reviewed: 79/79 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

Copilot review overview

🟢 Approval recommended

The implementation matches the stated requirements and is covered by focused integration tests across supported render modes.

Review effort: Balanced
Findings: None

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.

Copilot review overview

🟡 Changes recommended

Client discovery rejects valid project formats/locales, and upgrading existing WebAssembly projects can leave conflicting redirect components.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 High severity · 1 Medium severity

Open (3)

Comment thread src/dotnet-scaffolding/dotnet-scaffold/AspNet/Helpers/BlazorIdentityHelper.cs Outdated

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.

Copilot review overview

🟡 Changes recommended

Option filtering regresses existing semantics, legacy redirect components can still cause ambiguous Razor resolution, and required integration coverage remains incomplete.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity · 1 Low severity

Open (3)
Resolved since last review (3)

danroth27 added a commit that referenced this pull request Sep 23, 2026
Port the framework guard from #3836 using the existing target-framework helper. The passkey script is not available for .NET 8 or 9, so skip its step instead of failing scaffolding now that required-step failures propagate to the process exit code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e
@danroth27
danroth27 force-pushed the fix/3797-update-blazor-identity branch from 2a6a1ba to c7ebeb9 Compare September 23, 2026 20:36
@danroth27
danroth27 force-pushed the fix/3797-update-blazor-identity branch from c7ebeb9 to 0a2a979 Compare September 23, 2026 22:56
@danroth27
danroth27 requested a review from phenning September 23, 2026 23:19
@haileymck
haileymck requested a balanced review from Copilot September 24, 2026 17:50

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.

Copilot review overview

🟡 Changes recommended

Global WebAssembly or Auto projects with a custom client root namespace can generate an invalid Identity layout type reference.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (3)

haileymck pushed a commit that referenced this pull request Sep 24, 2026
* Propagate scaffolding failures to CLI exit codes

Return required-step failures through the command handler, runner, process entry point, and interactive flow. Preserve skipped and optional steps, report partial-change diagnostics, and add regression coverage.

Fixes #3845

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e

* Trim exit-code tests to meaningful regression coverage

Remove duplicate runner and direct-flow cases, low-value construction and empty-step checks, and redundant logging assertions. Retain process exit-code coverage, step ordering semantics, and built-in and external interactive failure propagation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e

* Revert core README changes from exit-code fix

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e

* Preserve command failures through interactive flow fallback

Cache the command execution result and reuse it when the interactive flow invokes RunAsync after validation failure. Exercise production interactive mode with an isolated Windows console buffer and assert the fallback failure and exactly one execution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e

* Skip Blazor Identity passkey script before .NET 10

Port the framework guard from #3836 using the existing target-framework helper. The passkey script is not available for .NET 8 or 9, so skip its step instead of failing scaffolding now that required-step failures propagate to the process exit code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e

* Return portable failure code for interactive flow exceptions

Report unexpected interactive flow errors and return 1 instead of int.MinValue, which becomes success on Unix. Cover successful, nonzero, and exception results.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e

* Make scaffold exit codes reflect package and tool failures

Stop on failed package additions, distinguish matching existing static files from conflicts, propagate tool manager failures, and normalize negative interactive flow results at the common runner boundary. Add focused end-to-end and unit regressions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e

---------

Copilot-Session: 71b25d6d-c063-4036-bebc-b34f1487819e
danroth27 and others added 22 commits September 24, 2026 14:51
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Flatten template filtering, move invariant calculations outside the loop, and clarify client redirect placement. Strengthen output-path assertions and cover framework-specific provider and redirect decisions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Allow !Option conditions in code-modification recipes and use !InteractiveServer to match the Blazor template's authorization registration. Document and test option matching, update integration assertions, and retain the requested redirect-comment spacing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Use a smaller CSS insertion anchor while preserving template rule order, and convert the .NET 9 recipe to UTF-8. Remove test-only friend access and its dependent tests, restore unrelated README and CLI runner changes, and move MSBuild evaluation details into reference documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Consolidate overwrite coverage, remove overlapping scenarios and cosmetic assertions, and exercise CSS edits through representative fixtures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Separate interactivity and validation scenarios, share project setup, and use ordinary project references in happy-path coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Insert account navigation independently of layout indentation, including apps upgraded from .NET 10, and cover overwrite idempotence in the existing integration case.

Align .NET 11 generated C# import ordering, provider namespace syntax, and ApplicationUser spacing with the project templates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Use 11.0.*-* for WebAssembly dependencies in the Identity fixtures, accepting stable and prerelease packages without a point-in-time RC build pin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Load configuration-relative text fragments with explicit validation. Share navigation CSS and code across .NET 9-11 and navigation markup between the .NET 11 server and client recipes.

Include fragments in development and packaged layouts, document their behavior, and cover invalid FileBlock definitions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Use one navigation fragment for .NET 9-11, adding the antiforgery token through ordered logout-form replacements for .NET 9/10. Remove the version-specific fragment packaging rules.

Remove RedirectToLogin namespace qualification and unused client namespace plumbing. Retain normal per-page Auto coverage without the legacy component collision fixture.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Include the default RouteView layout attribute so the Identity routing replacement is exercised without the legacy redirect collision setup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Extract the identical PageRenderMode block into a shared FileBlock fragment for .NET 9, 10, and 11 without changing generated content.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Restore the README to its pre-PR content.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Rename BlazorIdentityTestProject to BlazorTestProject, update its callers, and use a generic temporary-directory prefix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Remove the duplicate .NET 8 analysis-failure case and five low-value assertions while retaining focused behavioral coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Insert Identity client service registrations before builder.Build() for .NET 9 through 11, covering separate Build and RunAsync statements in the existing per-page Auto integration case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Cover async login validation, TempData status flow, and passkey display metadata in the existing .NET 11 integration case.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Preserve render-mode-aware routing and cascading authentication state. Remove conflicting host edits, hard-coded database fallback, redundant factory registration and duplicate imports; keep migrations middleware development-only.

Use realistic integration fixtures and verify generated routing and host configuration, including .NET 8 navigation and Razor code placement.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Include Microsoft.Data.SqlClient.Extensions.Azure for SQL Server projects targeting .NET 11 or later. Cover provider and framework boundaries and exercise SQL Server in the existing .NET 11 CLI integration test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Keep the matching-content and differing-content checks from main, cover explicit overwrite, and remove the obsolete unconditional existing-file success expectation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
Carry RootNamespace alongside the discovered WebAssembly project path and use it for client-hosted layouts. Extend the existing global interactivity cases to cover custom namespaces without adding test cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a37bc150-e82d-4428-8401-fd90abdc868d
@danroth27
danroth27 force-pushed the fix/3797-update-blazor-identity branch from 0a2a979 to 7d4cb81 Compare September 24, 2026 22:23
@danroth27
danroth27 requested a balanced review from Copilot September 24, 2026 22:57

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.

Copilot review overview

🔵 Needs a closer look

The broad authentication, security, generated-template, and cross-project changes warrant final human review despite strong test coverage and no additional defects found.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@phenning phenning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, but would like a final from Hailey, since she is most familiar with the changes here.

@haileymck
haileymck merged commit 0871f8e into main Sep 25, 2026
17 checks passed
@haileymck
haileymck deleted the fix/3797-update-blazor-identity branch September 25, 2026 16:08
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.

Update Blazor Identity scaffolder to align with the .NET 11 Blazor Web App template

4 participants