Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net identity 2.1 injecting IAuthenticationManager using StructureMap

Can anyone point me in the direction of some samples or instructions on how to achieve this please?

like image 538
wmcainsh Avatar asked Aug 28 '14 09:08

wmcainsh


1 Answers

I have not used StructureMap, but I have done this with Autofac and SimpleInjector.

Autofac registration would look like this:

builder.Register(c => HttpContext.Current.GetOwinContext().Authentication).As<IAuthenticationManager>();

Registration in SimpleInjector looks like this:

container.RegisterPerWebRequest(() => HttpContext.Current.GetOwinContext().Authentication);

And from looking on StructureMap tutorial I can guess that registration there would be something like this:

ForRequestedType<IAuthenticationManager>()
    .TheDefaultIs(() => HttpContext.Current.GetOwinContext().Authentication)
like image 121
trailmax Avatar answered Sep 17 '22 19:09

trailmax