authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 23:44:23 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-01 02:23:06 -07:00
log27873c7ccc0aed3bd3694fe2250d2cf2fd8101e5
tree14fa7f3e3ccc6b19363be282f5ab405b872ec7f0
parentbd3a5452ae3f88dcefd030bef36915079062308e
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

update to zig 0.15.2


2 files changed, 15 insertions(+), 19 deletions(-)

README.md+1-1
......@@ -3,7 +3,7 @@
33![loc](https://sloc.xyz/github/nektro/zig-oauth2)
44[![license](https://img.shields.io/github/license/nektro/zig-oauth2.svg)](https://github.com/nektro/zig-oauth2/blob/master/LICENSE)
55[![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro)
6[![Zig](https://img.shields.io/badge/Zig-0.14-f7a41d)](https://ziglang.org/)
6[![Zig](https://img.shields.io/badge/Zig-0.15-f7a41d)](https://ziglang.org/)
77[![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod)
88
99HTTP handler functions to allow you to easily add OAuth2 login support to your Zig application.
oauth2.zig+14-18
......@@ -313,9 +313,9 @@ pub fn Handlers(comptime T: type) type {
313313 try params.append("state", "none");
314314 const req_body = try params.encode();
315315
316 var req = try http_client.open(.POST, try std.Uri.parse(client.provider.token_url), .{
317 .server_header_buffer = &buf,
316 var req = try http_client.request(.POST, try std.Uri.parse(client.provider.token_url), .{
318317 .headers = .{
318 .accept_encoding = .{ .override = "identity" },
319319 .authorization = .{ .override = try nio.fmt.allocPrint(alloc, "Basic {s}", .{try extras.base64EncodeAlloc(alloc, try std.mem.join(alloc, ":", &.{ client.id, client.secret }))}) },
320320 .content_type = .{ .override = "application/x-www-form-urlencoded" },
321321 },
......@@ -325,14 +325,11 @@ pub fn Handlers(comptime T: type) type {
325325 .redirect_behavior = .not_allowed,
326326 });
327327 defer req.deinit();
328 req.transfer_encoding = .{ .content_length = req_body.len };
329 try req.send();
330 try req.writer().writeAll(req_body);
331 try req.finish();
332 try req.wait();
333 const body_content = try req.reader().readAllAlloc(alloc, 1024 * 1024 * 5);
334 if (req.response.status != .ok) std.log.scoped(.oauth).debug("{s}: {s}", .{ @tagName(req.response.status), body_content });
335 if (req.response.status != .ok) return error.OauthBadToken;
328 try req.sendBodyComplete(req_body);
329 var resp = try req.receiveHead(&.{});
330 const body_content = try resp.reader(&buf).allocRemaining(alloc, .limited(1024 * 1024 * 5));
331 if (resp.head.status != .ok) std.log.scoped(.oauth).debug("{s}: {s}", .{ @tagName(resp.head.status), body_content });
332 if (resp.head.status != .ok) return error.OauthBadToken;
336333 const val = try json.parseFromSlice(alloc, "body.json", body_content, .{ .maximum_depth = 100, .support_trailing_commas = true });
337334 val.acquire();
338335 const tt = val.root.object().getS("token_type").?;
......@@ -340,9 +337,9 @@ pub fn Handlers(comptime T: type) type {
340337 const at = val.root.object().getS("access_token") orelse return try fail(response_status, body_writer, "Identity Provider Login Error!\n{s}", .{body_content});
341338 val.release();
342339
343 var req2 = try http_client.open(.GET, try std.Uri.parse(client.provider.me_url), .{
344 .server_header_buffer = &buf,
340 var req2 = try http_client.request(.GET, try std.Uri.parse(client.provider.me_url), .{
345341 .headers = .{
342 .accept_encoding = .{ .override = "identity" },
346343 .authorization = .{ .override = try nio.fmt.allocPrint(alloc, "Bearer {s}", .{at}) },
347344 },
348345 .extra_headers = &.{
......@@ -351,12 +348,11 @@ pub fn Handlers(comptime T: type) type {
351348 .redirect_behavior = .not_allowed,
352349 });
353350 defer req2.deinit();
354 try req2.send();
355 try req2.finish();
356 try req2.wait();
357 const body_content2 = try req2.reader().readAllAlloc(alloc, 1024 * 1024 * 5);
358 if (req2.response.status != .ok) std.log.scoped(.oauth).debug("{s}: {s}", .{ @tagName(req2.response.status), body_content2 });
359 if (req2.response.status != .ok) return error.OauthBadUserinfo;
351 try req2.sendBodiless();
352 var resp2 = try req2.receiveHead(&.{});
353 const body_content2 = try resp2.reader(&buf).allocRemaining(alloc, .limited(1024 * 1024 * 5));
354 if (resp2.head.status != .ok) std.log.scoped(.oauth).debug("{s}: {s}", .{ @tagName(resp2.head.status), body_content2 });
355 if (resp2.head.status != .ok) return error.OauthBadUserinfo;
360356 const val2 = try json.parseFromSlice(alloc, "body2.json", body_content2, .{ .maximum_depth = 100, .support_trailing_commas = true });
361357 val2.acquire();
362358 const id = try fixId(val2.root.object().getAny(client.provider.id_prop).?);