most requests working (see below)
All checks were successful
continuous-integration/drone/push Build is passing

rest_json_1_work_with_lambda seems to fail
STS-generated keys not working
there might be an intermittent signature failure
This commit is contained in:
Emil Lerch 2022-01-19 19:29:58 -08:00
parent acba4d7962
commit e66c82468a
Signed by: lobo
GPG Key ID: A7B62D657EF764F8
3 changed files with 20 additions and 14 deletions

View File

@ -129,14 +129,15 @@ pub const AwsHttp = struct {
defer if (len) |l| self.allocator.free(l); defer if (len) |l| self.allocator.free(l);
request_cp.headers = request_headers.items; request_cp.headers = request_headers.items;
log.debug("All Request Headers (before signing. Count: {d}):", .{request_cp.headers.len}); // log.debug("All Request Headers (before signing. Count: {d}):", .{request_cp.headers.len});
for (request_cp.headers) |h| // for (request_cp.headers) |h| {
log.debug("\t{s}: {s}", .{ h.name, h.value }); // log.debug("\t{s}: {s}", .{ h.name, h.value });
// Signing will alter request headers // }
if (signing_config) |opts| request_cp = try signing.signRequest(self.allocator, request_cp, opts); if (signing_config) |opts| request_cp = try signing.signRequest(self.allocator, request_cp, opts);
log.debug("All Request Headers (after signing):", .{}); // log.debug("All Request Headers (after signing):", .{});
for (request_cp.headers) |h| // for (request_cp.headers) |h| {
log.debug("\t{s}: {s}", .{ h.name, h.value }); // log.debug("\t{s}: {s}", .{ h.name, h.value });
// }
defer { defer {
if (signing_config) |opts| { if (signing_config) |opts| {
signing.freeSignedRequest(self.allocator, &request_cp, opts); signing.freeSignedRequest(self.allocator, &request_cp, opts);
@ -150,12 +151,16 @@ pub const AwsHttp = struct {
for (request_cp.headers) |header| for (request_cp.headers) |header|
try headers.appendValue(header.name, header.value); try headers.appendValue(header.name, header.value);
log.debug("All Request Headers (zfetch):", .{}); log.debug("All Request Headers (zfetch):", .{});
for (headers.list.items) |h| for (headers.list.items) |h| {
log.debug("\t{s}: {s}", .{ h.name, h.value }); log.debug("\t{s}: {s}", .{ h.name, h.value });
}
// TODO: Construct URL with endpoint and request info // TODO: Construct URL with endpoint and request info
// TODO: We need the certificate trust chain // TODO: We need the certificate trust chain
var req = try zfetch.Request.init(self.allocator, "https://sts.us-west-2.amazonaws.com/", null); const url = try std.fmt.allocPrint(self.allocator, "{s}{s}", .{ endpoint.uri, request.path });
defer self.allocator.free(url);
log.debug("Request url: {s}", .{url});
var req = try zfetch.Request.init(self.allocator, url, null);
defer req.deinit(); defer req.deinit();
const method = std.meta.stringToEnum(zfetch.Method, request_cp.method).?; const method = std.meta.stringToEnum(zfetch.Method, request_cp.method).?;

View File

@ -165,8 +165,6 @@ pub fn signRequest(allocator: std.mem.Allocator, request: base.Request, config:
.value = signing_iso8601, .value = signing_iso8601,
}; };
rc.headers = newheaders[0 .. newheaders.len - 1]; rc.headers = newheaders[0 .. newheaders.len - 1];
for (rc.headers) |h|
std.log.debug("{d}/{d}", .{ h.name.len, h.value.len });
log.debug("Signing with access key: {s}", .{config.credentials.access_key}); log.debug("Signing with access key: {s}", .{config.credentials.access_key});
const canonical_request = try createCanonicalRequest(allocator, rc, config); const canonical_request = try createCanonicalRequest(allocator, rc, config);
defer { defer {

View File

@ -3,7 +3,7 @@ const aws = @import("aws.zig");
const json = @import("json.zig"); const json = @import("json.zig");
const version = @import("git_version.zig"); const version = @import("git_version.zig");
var verbose = true; var verbose: u8 = 0;
pub fn log( pub fn log(
comptime level: std.log.Level, comptime level: std.log.Level,
@ -11,8 +11,11 @@ pub fn log(
comptime format: []const u8, comptime format: []const u8,
args: anytype, args: anytype,
) void { ) void {
// Ignore aws_signing messages
if (verbose < 2 and scope == .aws_signing and @enumToInt(level) >= @enumToInt(std.log.Level.debug))
return;
// Ignore awshttp messages // Ignore awshttp messages
if (!verbose and scope == .awshttp and @enumToInt(level) >= @enumToInt(std.log.Level.debug)) if (verbose < 1 and scope == .awshttp and @enumToInt(level) >= @enumToInt(std.log.Level.debug))
return; return;
const scope_prefix = "(" ++ @tagName(scope) ++ "): "; const scope_prefix = "(" ++ @tagName(scope) ++ "): ";
const prefix = "[" ++ @tagName(level) ++ "] " ++ scope_prefix; const prefix = "[" ++ @tagName(level) ++ "] " ++ scope_prefix;
@ -52,7 +55,7 @@ pub fn main() anyerror!void {
std.log.info("{s} {s}", .{ arg, version.pretty_version }); std.log.info("{s} {s}", .{ arg, version.pretty_version });
first = false; first = false;
if (std.mem.eql(u8, "-v", arg)) { if (std.mem.eql(u8, "-v", arg)) {
verbose = true; verbose += 1;
continue; continue;
} }
inline for (@typeInfo(Tests).Enum.fields) |f| { inline for (@typeInfo(Tests).Enum.fields) |f| {