Skip to content

Identity Shims: Delegate ApplicationUserManager and ApplicationSignInManager to ASP.NET Core Identity #525

@csharpfritz

Description

@csharpfritz

Summary

The L1 migration script (�wfc-migrate.ps1) currently generates stub Identity shims (IdentityShims.cs) that provide no-op implementations of ApplicationUserManager and ApplicationSignInManager. These stubs allow migrated code-behinds to compile but do not perform any real authentication or user management.

We should replace these stubs with delegation wrappers that forward calls to the modern ASP.NET Core Identity equivalents:

Web Forms (Identity v2) ASP.NET Core Identity
ApplicationUserManager UserManager
ApplicationSignInManager SignInManager
IdentityResult Microsoft.AspNetCore.Identity.IdentityResult
IdentityUser Microsoft.AspNetCore.Identity.IdentityUser
SignInStatus enum Microsoft.AspNetCore.Identity.SignInResult

Goals

  1. ApplicationUserManager wrapper Inject UserManager and delegate:

    • FindByIdAsync UserManager.FindByIdAsync
    • CreateAsync UserManager.CreateAsync
    • ChangePasswordAsync UserManager.ChangePasswordAsync
    • GeneratePasswordResetTokenAsync / ResetPasswordAsync
    • GenerateEmailConfirmationTokenAsync / ConfirmEmailAsync
    • Phone number, two-factor, and login management methods
  2. ApplicationSignInManager wrapper Inject SignInManager<IdentityUser> and delegate:

    • PasswordSignInAsync SignInManager.PasswordSignInAsync (map SignInStatus SignInResult)
    • TwoFactorSignInAsync SignInManager.TwoFactorSignInAsync
    • SignInAsync SignInManager.SignInAsync
  3. Registration Provide a services.AddWebFormsIdentityShims<TUser>() extension method that:

    • Registers ASP.NET Core Identity (AddIdentity<TUser, IdentityRole>)
    • Registers the delegation wrappers as scoped services
    • Configures EF Core Identity stores
  4. SignInStatus SignInResult mapping The delegation layer maps the Web Forms SignInStatus enum values to the ASP.NET Core SignInResult properties (Succeeded, IsLockedOut, RequiresTwoFactor, etc.)

Context

  • The L1 script generates IdentityShims.cs with no-op stubs so code compiles
  • The L2 Identity migration skill (bwfc-identity-migration) currently rewrites Account pages from scratch
  • This feature would provide a middle ground: code-behinds compile AND auth actually works, before full L2 rewrite
  • Affects all projects that have Identity/Account pages (detected by presence of Account/*.aspx in source)

Acceptance Criteria

  • ApplicationUserManager delegates all methods to UserManager<TUser>
  • ApplicationSignInManager delegates all methods to SignInManager<TUser>
  • SignInStatus values correctly map to SignInResult
  • services.AddWebFormsIdentityShims<TUser>() extension registers everything
  • Existing migrated Account page code-behinds compile and auth operations work
  • Unit tests cover the delegation mapping
  • L1 script updated to generate delegation shims (with the DI registration call) instead of no-op stubs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions