From 3d48879db07da998d9d7fe039f055e4b2383a04b Mon Sep 17 00:00:00 2001 From: Michael Peng Date: Mon, 9 May 2022 16:45:07 -0700 Subject: [PATCH] Alter key generation logic V4 (#3040) * Alter key generation logic * Revert changes to csproj * Corrected WebHost version --- .../Azure.Functions.Cli.csproj | 2 +- .../Kubernetes/FuncKeys/FuncAppKeysHelper.cs | 26 +++++-------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj b/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj index ed31a1656..5a6335098 100644 --- a/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj +++ b/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj @@ -1,4 +1,4 @@ - + Exe net6.0 diff --git a/src/Azure.Functions.Cli/Kubernetes/FuncKeys/FuncAppKeysHelper.cs b/src/Azure.Functions.Cli/Kubernetes/FuncKeys/FuncAppKeysHelper.cs index c4f8b6f72..953d59780 100644 --- a/src/Azure.Functions.Cli/Kubernetes/FuncKeys/FuncAppKeysHelper.cs +++ b/src/Azure.Functions.Cli/Kubernetes/FuncKeys/FuncAppKeysHelper.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Security.Cryptography; using Azure.Functions.Cli.Kubernetes.Models.Kubernetes; +using Microsoft.Azure.WebJobs.Script.WebHost.Security; namespace Azure.Functions.Cli.Kubernetes.FuncKeys { @@ -26,16 +25,16 @@ public static IDictionary CreateKeys(IEnumerable functio { var funcAppKeys = new Dictionary { - { MasterKey, GenerateKey() }, - { HostFunctionKey, GenerateKey() }, - { HostSystemKey, GenerateKey() } + { MasterKey, SecretGenerator.GenerateMasterKeyValue() }, + { HostFunctionKey, SecretGenerator.GenerateFunctionKeyValue() }, + { HostSystemKey, SecretGenerator.GenerateSystemKeyValue() } }; if (functionNames?.Any() == true) { foreach (var funcName in functionNames) { - funcAppKeys[$"{FunctionKeyPrefix}{funcName.ToLower()}.{FunctionDefaultKeyName}"] = GenerateKey(); + funcAppKeys[$"{FunctionKeyPrefix}{funcName.ToLower()}.{FunctionDefaultKeyName}"] = SecretGenerator.GenerateFunctionKeyValue(); } } @@ -89,18 +88,5 @@ public static void CreateFuncAppKeysVolumeMountDeploymentResource(IEnumerable