diff --git a/src/Azure.Functions.Cli/Actions/HostActions/Startup.cs b/src/Azure.Functions.Cli/Actions/HostActions/Startup.cs index c104d49a0..9ea7d8069 100644 --- a/src/Azure.Functions.Cli/Actions/HostActions/Startup.cs +++ b/src/Azure.Functions.Cli/Actions/HostActions/Startup.cs @@ -3,6 +3,7 @@ using Azure.Functions.Cli.Diagnostics; using Azure.Functions.Cli.ExtensionBundle; using Azure.Functions.Cli.Helpers; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Azure.WebJobs.Script; @@ -73,6 +74,8 @@ public IServiceProvider ConfigureServices(IServiceCollection services) .AddScheme>(ArmAuthenticationDefaults.AuthenticationScheme, _ => { }); } + services.AddSingleton(); + services.AddWebJobsScriptHostAuthorization(); services.AddMvc() diff --git a/src/Azure.Functions.Cli/Actions/HostActions/WebHost/Security/CliAuthenticationHandler.cs b/src/Azure.Functions.Cli/Actions/HostActions/WebHost/Security/CliAuthenticationHandler.cs index f61de66ae..a646e54e6 100644 --- a/src/Azure.Functions.Cli/Actions/HostActions/WebHost/Security/CliAuthenticationHandler.cs +++ b/src/Azure.Functions.Cli/Actions/HostActions/WebHost/Security/CliAuthenticationHandler.cs @@ -8,6 +8,9 @@ using System.Security.Claims; using Microsoft.Azure.WebJobs.Script.WebHost.Security.Authentication; using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Azure.WebJobs.Script.WebHost.Security.Authorization; +using Microsoft.Azure.WebJobs.Script.Description; namespace Azure.Functions.Cli.Actions.HostActions.WebHost.Security { @@ -33,4 +36,14 @@ protected override Task HandleAuthenticateAsync() return Task.FromResult(result); } } + + public class CoreToolsAuthorizationHandler : AuthorizationHandler + { + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, FunctionAuthorizationRequirement requirement, FunctionDescriptor resource) + { + context.Succeed(requirement); + + return Task.CompletedTask; + } + } } diff --git a/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj b/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj index 44514bcc4..94b67ec4e 100644 --- a/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj +++ b/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj @@ -149,7 +149,7 @@ - + diff --git a/test/Azure.Functions.Cli.Tests/E2E/StartTests.cs b/test/Azure.Functions.Cli.Tests/E2E/StartTests.cs index 359c4cb9a..d9676d01b 100644 --- a/test/Azure.Functions.Cli.Tests/E2E/StartTests.cs +++ b/test/Azure.Functions.Cli.Tests/E2E/StartTests.cs @@ -531,7 +531,7 @@ await CliTester.Run(new RunConfiguration }, _output); } - [Theory] + [Theory(Skip = "https://github.com/Azure/azure-functions-core-tools/issues/3644")] [InlineData("dotnet")] [InlineData("dotnet-isolated")] public async Task start_with_user_secrets(string language)