Not sure if you've seen my reply on slack, but instead of overwriting UmbracoDefaultOwinStartup you can create a component and listen to the UmbracoDefaultOwinStartup.MiddlewareConfigured event. This event is fired when Umbraco is done configuring Owin
using Owin;
using Umbraco.Core.Composing;
using Umbraco.Web;
namespace Website
{
public class MyComposer : ComponentComposer<MyComponent>, IUserComposer
{
}
public class MyComponent : IComponent
{
public MyComponent()
{
// inject dependencies in the constructor
}
public void Initialize()
{
UmbracoDefaultOwinStartup.MiddlewareConfigured += (_, e) => ConfigureMiddleware(e.AppBuilder);
}
private void ConfigureMiddleware(IAppBuilder app)
{
// this is called when Umbraco is done configuring the Owin middleware
}
public void Terminate()
{
}
}
}
Inject IUmbracoContextFactory into OwinStartup class
So I have a class that inherits from UmbracoDefaultOwinStartup its in an inherited site. Its making use of content service to get some config stuff.
Is it possible to inject in IUmbracoContextFactory then I can use the cache to do the same thing or is this to early in the pipleine?
Ismail
Hi Ismail
Not sure if you've seen my reply on slack, but instead of overwriting UmbracoDefaultOwinStartup you can create a component and listen to the UmbracoDefaultOwinStartup.MiddlewareConfigured event. This event is fired when Umbraco is done configuring Owin
Hmm, but i need todo this:
what maybe i cannot do in the composer?
It's AFAIK not possible to inject stuff into the OwinStartup class But looking at the UmbracoDefaultOwinStartup, ConfigureUmbracoAuthentication() is called right before the event is triggered https://github.com/umbraco/Umbraco-CMS/blob/8f32fce7818a556d4879e66851dbe91221c63fdc/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs#L69 (the FinalizeMiddlewareConfiguration triggers the event)
So you should be able to run you're auth configuration in the ConfigureMiddleware method in the Component example shown above
Awesomes will give that a whirl, thanks for you help.
is working on a reply...