zig pds
0

Configure Feed

Select the types of activity you want to include in your feed.

Read create account auth before body

+5 -4
+5 -4
src/atproto/server.zig
··· 46 46 } 47 47 48 48 pub fn createAccount(request: *http.Server.Request) !void { 49 + const authorization = http_api.headerValue(request, "authorization"); 49 50 var body_buf: [8192]u8 = undefined; 50 51 const body = try http_api.readBody(request, &body_buf); 51 52 ··· 71 72 } 72 73 73 74 const existing_did = zat.json.getString(parsed.value, "did"); 74 - if (existing_did == null and http_api.headerValue(request, "authorization") == null) { 75 + if (existing_did == null and authorization == null) { 75 76 return http_api.xrpcError(request, .bad_request, "InvalidRequest", "zds currently requires a did for account migration"); 76 77 } 77 78 const did = existing_did orelse { ··· 82 83 return http_api.xrpcError(request, .bad_request, "InvalidDid", "invalid did"); 83 84 } 84 85 std.debug.print("xrpc createAccount attempt did={s} handle={s}\n", .{ did, handle }); 85 - try verifyCreateAccountServiceAuth(request, allocator, did); 86 + try verifyCreateAccountServiceAuth(request, allocator, authorization, did); 86 87 87 88 const account = store.createAccount(allocator, handle, email, password, did, false) catch { 88 89 std.debug.print("xrpc createAccount rejected account_exists_or_store_error did={s} handle={s}\n", .{ did, handle }); ··· 139 140 .{ .name = "connection", .value = "close" }, 140 141 }; 141 142 142 - fn verifyCreateAccountServiceAuth(request: *http.Server.Request, allocator: std.mem.Allocator, did: []const u8) !void { 143 - const raw_header = http_api.headerValue(request, "authorization") orelse { 143 + fn verifyCreateAccountServiceAuth(request: *http.Server.Request, allocator: std.mem.Allocator, maybe_authorization: ?[]const u8, did: []const u8) !void { 144 + const raw_header = maybe_authorization orelse { 144 145 std.debug.print("xrpc createAccount service_auth missing did={s}\n", .{did}); 145 146 return http_api.xrpcError(request, .unauthorized, "AuthenticationRequired", "service auth required to migrate an existing did"); 146 147 };