U4-8286 Add OWIN startup events to the UmbracoDefaultOwinStartup class
This commit is contained in:
@@ -72,6 +72,11 @@ namespace Umbraco.Core
|
||||
/// <summary>
|
||||
/// Override init and raise the event
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// DID YOU KNOW? The Global.asax Init call is the thing that initializes all of the httpmodules, ties up a bunch of stuff with IIS, etc...
|
||||
/// Therefore, since OWIN is an HttpModule when running in IIS/ASP.Net the OWIN startup is not executed until this method fires and by that
|
||||
/// time, Umbraco has performed it's bootup sequence.
|
||||
/// </remarks>
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
15
src/Umbraco.Web/OwinMiddlewareConfiguredEventArgs.cs
Normal file
15
src/Umbraco.Web/OwinMiddlewareConfiguredEventArgs.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using Owin;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
public class OwinMiddlewareConfiguredEventArgs : EventArgs
|
||||
{
|
||||
public OwinMiddlewareConfiguredEventArgs(IAppBuilder appBuilder)
|
||||
{
|
||||
AppBuilder = appBuilder;
|
||||
}
|
||||
|
||||
public IAppBuilder AppBuilder { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,31 @@ namespace Umbraco.Web.Security.Identity
|
||||
{
|
||||
public static class AppBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Called at the end of configuring middleware
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <remarks>
|
||||
/// This could be used for something else in the future - maybe to inform Umbraco that middleware is done/ready, but for
|
||||
/// now this is used to raise the custom event
|
||||
///
|
||||
/// This is an extension method in case developer entirely replace the UmbracoDefaultOwinStartup class, in which case they will
|
||||
/// need to ensure they call this extension method in their startup class.
|
||||
///
|
||||
/// TODO: Move this method in v8, it doesn't belong in this namespace/extension class
|
||||
/// </remarks>
|
||||
public static void FinalizeMiddlewareConfiguration(this IAppBuilder app)
|
||||
{
|
||||
UmbracoDefaultOwinStartup.OnMiddlewareConfigured(new OwinMiddlewareConfiguredEventArgs(app));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the OWIN logger to use Umbraco's logging system
|
||||
/// </summary>
|
||||
/// <param name="app"></param>
|
||||
/// <remarks>
|
||||
/// TODO: Move this method in v8, it doesn't belong in this namespace/extension class
|
||||
/// </remarks>
|
||||
public static void SetUmbracoLoggerFactory(this IAppBuilder app)
|
||||
{
|
||||
app.SetLoggerFactory(new OwinLoggerFactory());
|
||||
|
||||
@@ -349,6 +349,7 @@
|
||||
<Compile Include="Mvc\ModelBindingException.cs" />
|
||||
<Compile Include="Mvc\RenderIndexActionSelectorAttribute.cs" />
|
||||
<Compile Include="Mvc\ValidateMvcAngularAntiForgeryTokenAttribute.cs" />
|
||||
<Compile Include="OwinMiddlewareConfiguredEventArgs.cs" />
|
||||
<Compile Include="PropertyEditors\DatePreValueEditor.cs" />
|
||||
<Compile Include="PropertyEditors\DecimalPropertyEditor.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\ImageCropDataSetConverter.cs" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Web;
|
||||
using System;
|
||||
using System.Web;
|
||||
using Microsoft.Owin;
|
||||
using Microsoft.Owin.Extensions;
|
||||
using Microsoft.Owin.Logging;
|
||||
@@ -59,12 +60,24 @@ namespace Umbraco.Web
|
||||
app
|
||||
.UseUmbracoBackOfficeCookieAuthentication(ApplicationContext, PipelineStage.Authenticate)
|
||||
.UseUmbracoBackOfficeExternalCookieAuthentication(ApplicationContext, PipelineStage.Authenticate)
|
||||
.UseUmbracoPreviewAuthentication(ApplicationContext, PipelineStage.Authorize);
|
||||
.UseUmbracoPreviewAuthentication(ApplicationContext, PipelineStage.Authorize)
|
||||
.FinalizeMiddlewareConfiguration();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised when the middelware has been configured
|
||||
/// </summary>
|
||||
public static event EventHandler<OwinMiddlewareConfiguredEventArgs> MiddlewareConfigured;
|
||||
|
||||
protected virtual ApplicationContext ApplicationContext
|
||||
{
|
||||
get { return ApplicationContext.Current; }
|
||||
}
|
||||
|
||||
internal static void OnMiddlewareConfigured(OwinMiddlewareConfiguredEventArgs args)
|
||||
{
|
||||
var handler = MiddlewareConfigured;
|
||||
if (handler != null) handler(null, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user