Closed cleversolutions closed 4 years ago
It's the order of registrations can you post the whole owin file?
Thanks @Shazwazza, nothing crazy, just the default example:
using Microsoft.Owin;
using Northbayproud;
using Owin;
using Umbraco.Web;
//To use this startup class, change the appSetting value in the web.config called
// "owin:appStartup" to be "UmbracoStandardOwinStartup"
[assembly: OwinStartup("UmbracoStandardOwinStartup", typeof(UmbracoStandardOwinStartup))]
namespace Northbayproud
{
public class UmbracoStandardOwinStartup : UmbracoDefaultOwinStartup
{
public override void Configuration(IAppBuilder app)
{
//ensure the default options are configured
base.Configuration(app);
//configure token auth
app.UseUmbracoBackOfficeTokenAuth();
}
}
}
I've also tried calling it in ConfigureUmbracoAuthentication
like so:
using Microsoft.Owin;
using Owin;
using U8PreviewProblem;
using Umbraco.Web;
//To use this startup class, change the appSetting value in the web.config called
// "owin:appStartup" to be "UmbracoStandardOwinStartup"
[assembly: OwinStartup("UmbracoStandardOwinStartup", typeof(UmbracoStandardOwinStartup))]
namespace U8PreviewProblem
{
/// <summary>
/// A standard way to configure OWIN for Umbraco
/// </summary>
/// <remarks>
/// The startup type is specified in appSettings under owin:appStartup - change it to "UmbracoStandardOwinStartup" to use this class.
/// </remarks>
public class UmbracoStandardOwinStartup : UmbracoDefaultOwinStartup
{
/// <summary>
/// Configures the back office authentication for Umbraco
/// </summary>
/// <param name="app"></param>
protected override void ConfigureUmbracoAuthentication(IAppBuilder app)
{
//ensure the default options are configured
base.Configuration(app);
//configure token auth
app.UseUmbracoBackOfficeTokenAuth();
}
}
}
Interesting, you can see where the preview authentication is added here https://github.com/umbraco/Umbraco-CMS/blob/v8/contrib/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs#L102
For whatever reason the ordering is affecting this. I remember something about this but can't remember the details. In ConfigureUmbracoAuthentication
you can try app.UseUmbracoBackOfficeTokenAuth();
before base.Configuration(app);
and see what happens?
Else you can replace the entire call to ConfigureUmbracoAuthentication
with this block https://github.com/umbraco/Umbraco-CMS/blob/v8/contrib/src/Umbraco.Web/UmbracoDefaultOwinStartup.cs#L95
and put app.UseUmbracoBackOfficeTokenAuth
before the UseUmbracoPreviewAuthentication
call.
Let me know what does/doesn't work.
Thanks @Shazwazza callingapp.UseUmbracoBackOfficeTokenAuth();
before base.Configuration(app);
did the trick. I'll submit a PR shortly to update the startup classes that are shipped.
Fixed in #39.
This sounds strange, but enabling back office token authentication by uncommenting the line
app.UseUmbracoBackOfficeTokenAuth(new BackOfficeAuthServerProviderOptions());
breaks preview. Preview an unpublished page and you get a 404. Preview a published page and you don't see any changes.