mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user