Asp.net core DefaultIdentity with DefaultUI and custom UserStore

SelAromDotNet 1 Reputation point
2022-07-13T03:10:04.213+00:00

I have created an asp.net core .net 6 website and on setup selected the option for individual accounts. It scaffolded up the EF identity, which I do not want to use...

through various trial and error, I've managed to implement the custom classes like UserStore to authenticate against my custom provider and it's getting there...

however I wanted to keep the DefaultUI it registers to leverage the login/user management features it provides. Unfortunately, this implementation seems to heavily rely on specific defaults and implementations of the EF version of Identity, such as IUserPhoneNumberStore and IUserAuthenticatorKeyStore for two factor authentication.

looking at the scaffolded bits of the Identity as shown here (https://andrewlock.net/customising-aspnetcore-identity-without-editing-the-pagemodel/) these features are indeed non-optional components of the default UI...

It appears I have three options: 1) implement all of these features in the user store even though I don't want to use them so the pages load and maybe use CSS to hide them in the ui 2) scaffold these pages and remove these dependencies or 3) build my own UI, which is basically option 2 but with more work...

This feels like an oversight to me; wasn't the entire point of Identity to make this plug and play and/or customizeable based on the features implemented? I see in some of the identity code it checks for these features (like if (this.userManager is IUserPhoneNumberStore) to skip unused features) but the UI pages are not doing this, and simply expect these to be present.

Is this intentionally done, and if so what is the reason to so tightly couple it to this setup specifically? I noticed the Add Scaffolded Item feature in VS also requires a data context, even though I'm not using one, so this supports the idea that Default UI is specifically only designed to be used with EF's identity implementation...

or is it perhaps something that just hasn't been done yet, and I could maybe do a PR for to add such checks, would such a change be valid and/or useful?

do I have any other options here? is there another UI that doesn't have such coupling?

many thanks!

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,148 questions
{count} votes