wip debugging the s3 key generation
This commit is contained in:
parent
c7bf3d3444
commit
69fed10f69
|
@ -81,23 +81,26 @@ public partial class Db
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonPayload = new JsonObject { ["name"] = user.Email, ["operations"] = new JsonArray{ "getObject", "listBucket" }, ["content"] = instList};
|
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}";
|
var signature = $"POST /v2/access-key\n{jsonPayload}\n\n\n{((DateTimeOffset)expiration).ToUnixTimeSeconds()}";
|
||||||
using var hmacSha1 = new HMACSHA1(Encoding.UTF8.GetBytes(secret));
|
using var hmacSha256 = new HMACSHA256(Encoding.UTF8.GetBytes(secret));
|
||||||
|
|
||||||
signature = Encoding.UTF8
|
signature = Encoding.UTF8
|
||||||
.GetBytes(signature)
|
.GetBytes(signature)
|
||||||
.Apply(hmacSha1.ComputeHash)
|
.Apply(hmacSha256.ComputeHash)
|
||||||
.Apply(Convert.ToBase64String);
|
.Apply(Convert.ToBase64String);
|
||||||
|
|
||||||
var keyJson = url
|
var keyJson = url
|
||||||
.WithHeader("Authorization", $"EXO2-HMAC-SHA256 credential={apiKey},expires={((DateTimeOffset)expiration).ToUnixTimeSeconds()},signature={signature}")
|
.WithHeader("Authorization",
|
||||||
.PostJsonAsync(jsonPayload.ToString())
|
$"EXO2-HMAC-SHA256 credential={apiKey},expires={((DateTimeOffset)expiration).ToUnixTimeSeconds()},signature={signature}");
|
||||||
|
|
||||||
|
|
||||||
|
var result = keyJson.PostJsonAsync(jsonPayload.ToString())
|
||||||
.ReceiveJson()
|
.ReceiveJson()
|
||||||
.Result;
|
.Result;
|
||||||
|
return result;
|
||||||
return SetUserS3ApiKey(user, keyJson.GetValue("key"));
|
// return SetUserS3ApiKey(user, keyJson.GetValue("key"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result SetUserS3ApiKey(User user, String key)
|
public Result SetUserS3ApiKey(User user, String key)
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue