mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
add web bot auth args
This commit is contained in:
@@ -23,6 +23,8 @@ const Allocator = std.mem.Allocator;
|
|||||||
const log = @import("log.zig");
|
const log = @import("log.zig");
|
||||||
const dump = @import("browser/dump.zig");
|
const dump = @import("browser/dump.zig");
|
||||||
|
|
||||||
|
const WebBotAuth = @import("browser/WebBotAuth.zig");
|
||||||
|
|
||||||
pub const RunMode = enum {
|
pub const RunMode = enum {
|
||||||
help,
|
help,
|
||||||
fetch,
|
fetch,
|
||||||
@@ -161,6 +163,17 @@ pub fn cdpTimeout(self: *const Config) usize {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn webBotAuth(self: *const Config) ?WebBotAuth {
|
||||||
|
return switch (self.mode) {
|
||||||
|
inline .serve, .fetch, .mcp => |opts| WebBotAuth{
|
||||||
|
.key_file = opts.common.web_bot_auth_key_file orelse return null,
|
||||||
|
.keyid = opts.common.web_bot_auth_keyid orelse return null,
|
||||||
|
.domain = opts.common.web_bot_auth_domain orelse return null,
|
||||||
|
},
|
||||||
|
.help, .version => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn maxConnections(self: *const Config) u16 {
|
pub fn maxConnections(self: *const Config) u16 {
|
||||||
return switch (self.mode) {
|
return switch (self.mode) {
|
||||||
.serve => |opts| opts.cdp_max_connections,
|
.serve => |opts| opts.cdp_max_connections,
|
||||||
@@ -227,6 +240,10 @@ pub const Common = struct {
|
|||||||
log_format: ?log.Format = null,
|
log_format: ?log.Format = null,
|
||||||
log_filter_scopes: ?[]log.Scope = null,
|
log_filter_scopes: ?[]log.Scope = null,
|
||||||
user_agent_suffix: ?[]const u8 = null,
|
user_agent_suffix: ?[]const u8 = null,
|
||||||
|
|
||||||
|
web_bot_auth_key_file: ?[]const u8 = null,
|
||||||
|
web_bot_auth_keyid: ?[]const u8 = null,
|
||||||
|
web_bot_auth_domain: ?[]const u8 = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Pre-formatted HTTP headers for reuse across Http and Client.
|
/// Pre-formatted HTTP headers for reuse across Http and Client.
|
||||||
@@ -334,6 +351,14 @@ pub fn printUsageAndExit(self: *const Config, success: bool) void {
|
|||||||
\\--user_agent_suffix
|
\\--user_agent_suffix
|
||||||
\\ Suffix to append to the Lightpanda/X.Y User-Agent
|
\\ Suffix to append to the Lightpanda/X.Y User-Agent
|
||||||
\\
|
\\
|
||||||
|
\\--web_bot_auth_key_file
|
||||||
|
\\ Path to the Ed25519 private key PEM file.
|
||||||
|
\\
|
||||||
|
\\--web_bot_auth_keyid
|
||||||
|
\\ The JWK thumbprint of your public key.
|
||||||
|
\\
|
||||||
|
\\--web_bot_auth_directory
|
||||||
|
\\ Your domain e.g. yourdomain.com
|
||||||
;
|
;
|
||||||
|
|
||||||
// MAX_HELP_LEN|
|
// MAX_HELP_LEN|
|
||||||
@@ -855,5 +880,32 @@ fn parseCommonArg(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, "--web_bot_auth_key_file", opt)) {
|
||||||
|
const str = args.next() orelse {
|
||||||
|
log.fatal(.app, "missing argument value", .{ .arg = "--web_bot_auth_key_file" });
|
||||||
|
return error.InvalidArgument;
|
||||||
|
};
|
||||||
|
common.web_bot_auth_key_file = try allocator.dupe(u8, str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, "--web_bot_auth_keyid", opt)) {
|
||||||
|
const str = args.next() orelse {
|
||||||
|
log.fatal(.app, "missing argument value", .{ .arg = "--web_bot_auth_keyid" });
|
||||||
|
return error.InvalidArgument;
|
||||||
|
};
|
||||||
|
common.web_bot_auth_keyid = try allocator.dupe(u8, str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.mem.eql(u8, "--web_bot_auth_domain", opt)) {
|
||||||
|
const str = args.next() orelse {
|
||||||
|
log.fatal(.app, "missing argument value", .{ .arg = "--web_bot_auth_domain" });
|
||||||
|
return error.InvalidArgument;
|
||||||
|
};
|
||||||
|
common.web_bot_auth_domain = try allocator.dupe(u8, str);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
23
src/network/WebBotAuth.zig
Normal file
23
src/network/WebBotAuth.zig
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
|
||||||
|
//
|
||||||
|
// Francis Bouvier <francis@lightpanda.io>
|
||||||
|
// Pierre Tachoire <pierre@lightpanda.io>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
const WebBotAuth = @This();
|
||||||
|
|
||||||
|
key_file: []const u8,
|
||||||
|
keyid: []const u8,
|
||||||
|
domain: []const u8,
|
||||||
Reference in New Issue
Block a user