Updating HMAC signature (#621)

This fixes an issue with the API key auth with Flow assuming the external URL will match the internal one (which fails when put being a gateway with TLS termination)
This commit is contained in:
Kevin B
2025-04-27 11:53:10 -07:00
committed by GitHub
parent 3a94c06325
commit fc7c462ec6

View File

@@ -15,8 +15,14 @@ public class HmacAuthHttpClientHandler(HttpMessageHandler innerHandler) : Delega
var key = keyParts[1];
var nonce = Guid.NewGuid().ToString();
string requestUri = "";
if (request.RequestUri is { } reqUri) {
requestUri = $"{reqUri.Host}{reqUri.PathAndQuery}";
}
var secondsSinceEpoch = HmacHelper.GetSecondsSinceEpoch();
var signature = HmacHelper.BuildSignature(hashedId, request.Method.Method, request.RequestUri?.AbsoluteUri ?? "", secondsSinceEpoch, nonce);
var signature = HmacHelper.BuildSignature(hashedId, request.Method.Method, requestUri, secondsSinceEpoch, nonce);
var secret = HmacHelper.Calculate(Convert.FromBase64String(key), signature);
request.Headers.Authorization = BuildHeader(hashedId, secret, nonce, secondsSinceEpoch);
}