-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Since updating to aspnetcore 3.0.101 this error occurs when trying to perform authorization on orchard controllers.
Error message:
Configure your application startup by adding app.UseAuthorization() inside the call to Configure(..) in the application startup code. The call to app.UseAuthorization() must appear between app.UseRouting() and app.UseEndpoints(...).
The 3.0.101 update now requires the UseAuthorization() middleware to be placed between UseRouting() and UseEndPoints().
This is introduced in this PR:
dotnet/aspnetcore#14893
And fixes issue:
dotnet/aspnetcore#14049.
My application requires to have authorization on API controllers which provide CMS content from Orchard.
In my Startup.cs I've configured the orchard middleware as such:
app.UseOrchardCore(ocb =>
{
ocb.UseAuthentication();
ocb.UseAuthorization();
});
This worked before the update, but on 3.0.101 throws the error message described above.
This means that technically the middleware should now be placed on this line.
https://github.com/OrchardCMS/OrchardCore/blob/dev/src/OrchardCore/OrchardCore/Modules/ModularTenantRouterMiddleware.cs#L125
Between appBuilder.UseRouting()
and appBuilder.UseEndpoints()
, but there's no way of doing that right now (that I'm aware of).
I'd assume that OrchardCore will still like to support adding authorization in it's request pipeline. I'm happy to submit a PR for a fix, but I'm not sure what approach for the fix would be here.