How to configure Owincontext Authentication in Simpleinjector 3.3.2?

Asked

Viewed 186 times

2

In my current application I use Simpleinjector 3.2.0 with a similar configuration to this:

var container = new Container();
container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

container.Register<IUserStore<Usuario>>(() => 
    new UserStore<Usuario>(container.GetInstance<IContext>() as DbContext), 
    Lifestyle.Scoped);

container.Register<AppUserManager>(Lifestyle.Scoped);
container.Register<AppSignInManager>(Lifestyle.Scoped);

// demais serviços
SimpleInjectorContainer.RegisterServices(container);

container.RegisterPerWebRequest(() =>
{
    if (HttpContext.Current != null && 
        HttpContext.Current.Items["owin.Environment"] == null && 
        container.IsVerifying())
        return new OwinContext().Authentication;

    return HttpContext.Current.GetOwinContext().Authentication;
});

container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

container.RegisterMvcIntegratedFilterProvider();
container.Verify();

DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));

I know this section for Owincontext Authentication configuration is obsolete.
How to set it up with Simpleinjector 3.3.2?

And this setting for Iuserstore<>.
I am using the container itself to get an instance of Dbcontext.
Go through Verify(), but am I really getting the instance of Iuserstore<> by this configuration?

Change something else to version 3.3.2?
I’m using . Net 4.6.1

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.