ASP.NET Identity 2 - ISecureDataFormat <> Injection

I have the same problem described here without an answer, just using Unity.

I am trying to register ISecureDataFormat<>

in the latest ASP2013 template (update 2) SPA / Web Api.

I tried

container.RegisterType(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>));
container.RegisterType<ISecureDataFormat<AuthenticationTicket>, SecureDataFormat<AuthenticationTicket>>();
container.RegisterType<ISecureDataFormat<AuthenticationTicket>, TicketDataFormat>();

      

It "works", but not really because then it complains about the next depenedency in that tree, IDataSerializer ... and then the next IDataProtector, which I haven't found any implementation for.

+2


source share


1 answer


I solved the following error in SimpleInjector with the following displays

container.Register<IDataSerializer<AuthenticationTicket>, TicketSerializer>();
container.Register<IDataProtector>(() => new DpapiDataProtectionProvider().Create("ASP.NET Identity"));

      



To find out which serializer was used, I noticed that the general ISecureDataFormat in AccountsController was of type AuthenticationTicket. When validating the IDataSerializer namespace, the TicketSerializer implements IDataSerializer.

To figure out the IDataProtector, I looked again in the IDataProtector namespace and found an implementation of IDataProtectionProvider.

+10


source







All Articles