2

is there a chance to user IdentityManager with an AspNet Core Identity?

I did not find any implementation of IIdentityManagerService for AspNetCoreidentity.

Alternatively, is there any replacement for IdentityManager when using AspnetCore identity?

Thank you.

Nkosi
  • 235,767
  • 35
  • 427
  • 472
Skorunka František
  • 5,102
  • 7
  • 44
  • 69
  • Check this out https://docs.asp.net/en/latest/security/authentication/identity.html – Nkosi Sep 11 '16 at 19:36
  • @Nkosi: I'm referring to IdentityManager (https://github.com/IdentityManager/IdentityManager) which is a SPA application for managing Users, Roles etc. – Skorunka František Sep 11 '16 at 20:12
  • Ok my misunderstanding – Nkosi Sep 11 '16 at 20:13
  • Hi @SkorunkaFrantišek I found your repo "https://github.com/skorunka/IdentityManager/" - could you please elaborate on how to implement it? I think I will figure it out, but for the moment I will postpone the implementation and focus on other stuff, I'm building a small demo app for a blog post using .net core, asp .net core and Identity Server on top of .net core Identity. Thanks :) – JimiSweden Dec 22 '16 at 08:24
  • Check https://github.com/IdentityManager/IdentityManager/blob/master/source/Host/Startup.cs. Instead of "InMemoryIdentityManagerService" use "AspNetCoreIdentityManagerService" – Skorunka František Dec 23 '16 at 14:33

1 Answers1

2

Yes, you can use IdentityManager to manage your AspNetIdentity users.

There is an implementation in IdentityManager itself called IdentityManager.AspNetIdentity. You may want to read through an article describing your scenario by Scott Hanselman.

What you essentially want to do is whereas you load your IdentityManagerService inheriting from the AspNetIdentityManagerService

public class ApplicationIdentityManagerService : AspNetIdentityManagerService<ApplicationUser, string, IdentityRole, string>
{
    public ApplicationIdentityManagerService(ApplicationUserManager userMgr, ApplicationRoleManager roleMgr) : base(userMgr, roleMgr)
    {
        // Nothing
    }
}

You can then plug it in into your factory as such:

app.Map("/users", idm =>
{
    var factory = new IdentityManagerServiceFactory();
    factory.IdentityManagerService = new Registration<IIdentityManagerService, ApplicationIdentityManagerService>();
    factory.Register(new Registration<ApplicationUserManager>());
    factory.Register(new Registration<ApplicationUserStore>());
    factory.Register(new Registration<ApplicationRoleManager>());
    factory.Register(new Registration<ApplicationRoleStore>());
    factory.Register(new Registration<ApplicationDbContext>(resolver => new ApplicationDbContext("dbase")));
    factory.Register(new Registration<ApplicationDbContext>());

    idm.UseIdentityManager(new IdentityManagerOptions { 
        Factory = factory
    });
});

Find a more complete example on the IdentityManager AspNetIdentity GitHub repo.

ranieuwe
  • 2,268
  • 1
  • 24
  • 30