Для этого требуется внешний ключ HMAC, передаваемый в заголовке, и некоторый текст JSON в теле в качестве входных данных, и его необходимо вычислить. новый HMAC локально и сравните их на подлинность.
Мои строки HMAC не совпадают, поскольку тип выходного тела такой, как показано ниже, когда оригинал отформатирован.
Мое тестирование сценарий:
Код: Выделить всё
// Add the required libraries
#r "Newtonsoft.Json"
#r "Microsoft.Azure.Workflows.Scripting"
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Microsoft.Extensions.Logging;
using Microsoft.Azure.Workflows.Scripting;
using Newtonsoft.Json.Linq;
using System.Security.Cryptography;
using System.Text;
///
/// Executes the inline csharp code.
///
///
The workflow context.
/// This is the entry-point to your code. The function signature should remain unchanged.
public static async Task Run(WorkflowContext context, ILogger log)
{
//String Variables (for clarity)
string compare = string.Empty;
string _origonalMessage = string.Empty;
string _origonalHmac = string.Empty;
string _calculatedHmac = string.Empty;
////Define the trigger output.
var triggerOutputs = (await context.GetTriggerResults().ConfigureAwait(false)).Outputs;
////Set the local HMAC key from the Azure Key Vault.
string secretKey = "HMAC-GG-TEST"; //
Подробнее здесь: [url]https://stackoverflow.com/questions/79275662/how-can-i-do-a-local-and-remote-hmac-comparison-in-an-azure-workflow[/url]
Мобильная версия