I am using ASP.NET Identity 2.2 in a Web API 2 project but I am unsure how to wire up the ISecureDataFormat<AuthenticationTicket>
dependency of the AccountController
using Autofac.
I tried this:
builder.RegisterType<ISecureDataFormat<AuthenticationTicket>>()
.As<TicketDataFormat>();
and getting error:
The type 'Microsoft.Owin.Security.ISecureDataFormat`1[Microsoft.Owin.Security.AuthenticationTicket]' is not assignable to service 'Microsoft.Owin.Security.DataHandler.TicketDataFormat'
None of the questions I came across seem to work using the latest stable release of ASP.NET Identity.
Any help is greatly appreciated.
You have to do the oposite. With Autofac you register a type as a Service.
builder.RegisterType<TicketDataFormat>()
.As<ISecureDataFormat<AuthenticationTicket>>();
and based on this answer, it seems that you also need to register a IDataSerializer<AuthenticationTicket>
and a IDataProtector
implementation.
builder.RegisterType<TicketSerializer>()
.As<IDataSerializer<AuthenticationTicket>>();
builder.Register(c => new DpapiDataProtectionProvider().Create("ASP.NET Identity"))
.As<IDataProtector>();