i have problem with owin configuration in typical asp.net project using Identity and castle windsor. The thing is i really like how identity and owin are managing all the user-stuff like sending cookie to loging user and so on but it requires the following code:
[assembly: OwinStartupAttribute(typeof(OwinStartUp.Startup))]
namespace OwinStartUp
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
app.CreatePerOwinContext(DbOwinHelper.CreateDbContext);
app.CreatePerOwinContext<ApplicationUserManager>(DbOwinHelper.CreateUserManager);
app.CreatePerOwinContext<ApplicationSignInManager>(DbOwinHelper.CreateSignInManager);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, MyIdentityUser, Guid>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
getUserIdCallback: (user) => Guid.Parse(user.GetUserId()))
}
});
}
}
}
so in e.g. controller i have to write this:
var signInManager = HttpContext.GetOwinContext().Get<ApplicationSignInManager>();
instead of this (which i preffer)
var signinmanager = container.Resolve<ISignInManager<IMyIdentityUser>>();
or at least
var signinmanager = container.Resolve<ApplicationSignInManager>();
How can i integrate windsor with owin pipeline? Or, in very least, how to use CookieAuthentication with my custom ApplicationSignInManager without owin (and without rewriting whole cookie authentication by my own)?
I have seen a lot of articles with castle windsor as owin dependecy resolver but it was mostly about self hosting owin.
Ok, so after almost a year i found answer here: WebApi + Simple Injector + OWIN
there is posted this post: https://simpleinjector.codeplex.com/discussions/539965 and then it leads here: Does SimpleInjector's WebAPIRequest lifetime include Message Handlers?
i think all 3 of this questions/answers combined are satisfying me.