Skip to content

Commit 1cfc78f

Browse files
author
Connor McMahon
authored
Move Linux consumption EasyAuth middleware after CORS in pipeline (#7315)
CORS middleware needs to execute before EasyAuth, as various CORS requests can happen without requiring authentication.
1 parent 4c4fb7d commit 1cfc78f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- My change description (#PR)
44
-->
55
- Added a feature flag to opt out of the default behavior where the host sets the environment name to `Development` when running in debug mode. To disable the behavior, set the app setting: `AzureWebJobsFeatureFlags` to `DisableDevModeInDebug`
6+
- Reorder CORS and EasyAuth middleware to prevent EasyAuth from blocking CORS requests (#7315)
67

78
**Release sprint:** Sprint 100
89
[ [bugs](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+100%22+label%3Abug+is%3Aclosed) | [features](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+100%22+label%3Afeature+is%3Aclosed) ]

src/WebJobs.Script.WebHost/WebScriptHostBuilderExtension.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,15 @@ public static IHostBuilder AddWebScriptHost(this IHostBuilder builder, IServiceP
9898
services.TryAddSingleton<IScriptWebHookProvider>(p => p.GetService<DefaultScriptWebHookProvider>());
9999
services.TryAddSingleton<IWebHookProvider>(p => p.GetService<DefaultScriptWebHookProvider>());
100100
services.TryAddSingleton<IJobHostMiddlewarePipeline, DefaultMiddlewarePipeline>();
101-
if (environment.IsLinuxConsumption())
102-
{
103-
services.TryAddEnumerable(ServiceDescriptor.Singleton<IJobHostHttpMiddleware, JobHostEasyAuthMiddleware>());
104-
}
105101
services.TryAddEnumerable(ServiceDescriptor.Singleton<IJobHostHttpMiddleware, CustomHttpHeadersMiddleware>());
106102
services.TryAddEnumerable(ServiceDescriptor.Singleton<IJobHostHttpMiddleware, HstsConfigurationMiddleware>());
107103
if (environment.IsLinuxConsumption())
108104
{
109105
services.AddSingleton<ICorsMiddlewareFactory, CorsMiddlewareFactory>();
110106
services.TryAddEnumerable(ServiceDescriptor.Singleton<IJobHostHttpMiddleware, JobHostCorsMiddleware>());
107+
108+
// EasyAuth must go after CORS, as CORS preflight requests can happen before authentication
109+
services.TryAddEnumerable(ServiceDescriptor.Singleton<IJobHostHttpMiddleware, JobHostEasyAuthMiddleware>());
111110
}
112111
services.TryAddSingleton<IScaleMetricsRepository, TableStorageScaleMetricsRepository>();
113112

0 commit comments

Comments
 (0)