wip debugging the s3 key generation

This commit is contained in:
Kim 2023-02-28 12:34:36 +01:00
parent c7bf3d3444
commit 69fed10f69
2 changed files with 11 additions and 8 deletions

View File

@ -81,23 +81,26 @@ public partial class Db
}
var jsonPayload = new JsonObject { ["name"] = user.Email, ["operations"] = new JsonArray{ "getObject", "listBucket" }, ["content"] = instList};
var expiration = DateTime.Now.AddHours(24);
var expiration = DateTime.Now.AddSeconds(60);
var signature = $"POST /v2/access-key\n{jsonPayload}\n\n\n{expiration}";
using var hmacSha1 = new HMACSHA1(Encoding.UTF8.GetBytes(secret));
var signature = $"POST /v2/access-key\n{jsonPayload}\n\n\n{((DateTimeOffset)expiration).ToUnixTimeSeconds()}";
using var hmacSha256 = new HMACSHA256(Encoding.UTF8.GetBytes(secret));
signature = Encoding.UTF8
.GetBytes(signature)
.Apply(hmacSha1.ComputeHash)
.Apply(hmacSha256.ComputeHash)
.Apply(Convert.ToBase64String);
var keyJson = url
.WithHeader("Authorization", $"EXO2-HMAC-SHA256 credential={apiKey},expires={((DateTimeOffset)expiration).ToUnixTimeSeconds()},signature={signature}")
.PostJsonAsync(jsonPayload.ToString())
.WithHeader("Authorization",
$"EXO2-HMAC-SHA256 credential={apiKey},expires={((DateTimeOffset)expiration).ToUnixTimeSeconds()},signature={signature}");
var result = keyJson.PostJsonAsync(jsonPayload.ToString())
.ReceiveJson()
.Result;
return SetUserS3ApiKey(user, keyJson.GetValue("key"));
return result;
// return SetUserS3ApiKey(user, keyJson.GetValue("key"));
}
public Result SetUserS3ApiKey(User user, String key)

Binary file not shown.