authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-03 02:03:42 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-03-03 02:03:42 -08:00
log3a4d58d06bdfbe4e6adb1219c580d07adb8a3488
tree9d0861ec3e5dc35db14bcf081c7e9d7baef0876e
parent49f33e433fd16fd4371a251590e39def192fff1e
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

replace UrlValues with url.SearchParams


3 files changed, 9 insertions(+), 7 deletions(-)

licenses.txt+3-1
......@@ -3,16 +3,18 @@ MIT:
33- This
44- git https://github.com/nektro/iguanaTLS
55- git https://github.com/nektro/zfetch
6- git https://github.com/nektro/zig-UrlValues
76- git https://github.com/nektro/zig-extras
87- git https://github.com/nektro/zig-sys-linux
98- git https://github.com/nektro/zig-tracer
9- git https://github.com/nektro/zig-unicode-ucd
1010- git https://github.com/truemedian/hzzp
1111- git https://github.com/kivikakk/htmlentities.zig
1212
1313MPL-2.0:
1414= https://spdx.org/licenses/MPL-2.0
1515- git https://github.com/nektro/zig-pek
16- git https://github.com/nektro/zig-unicode-idna
17- git https://github.com/nektro/zig-whatwg-url
1618
1719Unspecified:
1820- system_lib c
oauth2.zig+5-5
......@@ -6,7 +6,7 @@ const files = @import("./files.zig");
66const pek = @import("pek");
77const zfetch = @import("zfetch");
88const extras = @import("extras");
9const UrlValues = @import("UrlValues");
9const url = @import("url");
1010const Base = @This();
1111
1212pub const Provider = struct {
......@@ -254,7 +254,7 @@ pub fn Handlers(comptime T: type) type {
254254 const Self = @This();
255255 pub var clients: []Client = &.{};
256256
257 pub fn login(request: *std.http.Server.Request, body_writer: anytype, alloc: std.mem.Allocator, query: UrlValues, request_headers: *const std.StringHashMapUnmanaged(string), response_status: *std.http.Status, response_headers: *std.ArrayListUnmanaged(std.http.Header)) !void {
257 pub fn login(request: *std.http.Server.Request, body_writer: anytype, alloc: std.mem.Allocator, query: url.SearchParams, request_headers: *const std.StringHashMapUnmanaged(string), response_status: *std.http.Status, response_headers: *std.ArrayListUnmanaged(std.http.Header)) !void {
258258 if (query.get("with")) |with| {
259259 const client = clientByProviderId(Self.clients, with) orelse return try fail(response_status, body_writer, "Client with that ID not found!\n", .{});
260260 return try loginOne(request, alloc, T, client, T.callbackPath, request_headers, response_status, response_headers);
......@@ -271,13 +271,13 @@ pub fn Handlers(comptime T: type) type {
271271 });
272272 }
273273
274 pub fn callback(request: *std.http.Server.Request, body_writer: anytype, alloc: std.mem.Allocator, query: UrlValues, request_headers: *const std.StringHashMapUnmanaged(string), response_status: *std.http.Status, response_headers: *std.ArrayListUnmanaged(std.http.Header)) !void {
274 pub fn callback(request: *std.http.Server.Request, body_writer: anytype, alloc: std.mem.Allocator, query: url.SearchParams, request_headers: *const std.StringHashMapUnmanaged(string), response_status: *std.http.Status, response_headers: *std.ArrayListUnmanaged(std.http.Header)) !void {
275275 _ = request;
276276 const state = query.get("state") orelse return try fail(response_status, body_writer, "", .{});
277277 const client = clientByProviderId(Self.clients, state) orelse return try fail(response_status, body_writer, "error: No handler found for provider: {s}\n", .{state});
278278 const code = query.get("code") orelse return try fail(response_status, body_writer, "", .{});
279279
280 var params = UrlValues.init(alloc);
280 var params = url.SearchParams.init(alloc);
281281 try params.append("client_id", client.id);
282282 try params.append("client_secret", client.secret);
283283 try params.append("grant_type", "authorization_code");
......@@ -331,7 +331,7 @@ fn loginOne(request: *std.http.Server.Request, alloc: std.mem.Allocator, comptim
331331 try response_headers.append(alloc, .{ .name = "Location", .value = T.doneUrl });
332332 } else {
333333 const idp = client.provider;
334 var params = UrlValues.init(alloc);
334 var params = url.SearchParams.init(alloc);
335335 try params.append("client_id", client.id);
336336 try params.append("redirect_uri", try redirectUri(request_headers, alloc, callbackPath));
337337 try params.append("response_type", "code");
zig.mod+1-1
......@@ -9,4 +9,4 @@ dependencies:
99 - src: git https://github.com/nektro/zig-pek
1010 - src: git https://github.com/nektro/zfetch
1111 - src: git https://github.com/nektro/zig-extras
12 - src: git https://github.com/nektro/zig-UrlValues
12 - src: git https://github.com/nektro/zig-whatwg-url