Commit cd1f255
authored
fix: handle proxy authentication via CDP Fetch.authRequired (#1000)
* fix: handle proxy authentication via CDP Fetch.authRequired
Chrome's --proxy-server flag does not support credentials embedded in
the URL. When a proxy requires authentication, Chrome receives a 407
from the proxy but has no way to respond with credentials, resulting
in net::ERR_INVALID_AUTH_CREDENTIALS.
Fix by:
1. Parsing credentials from the proxy URL (already done by parse_proxy)
2. Storing them in DaemonState.proxy_credentials
3. Enabling Fetch.enable with handleAuthRequests: true
4. Responding to Fetch.authRequired events with Fetch.continueWithAuth
5. Passing only the server URL (without credentials) to --proxy-server
6. Forwarding credentials to the daemon via dedicated env vars
Also adds fallback to standard proxy env vars (HTTP_PROXY, HTTPS_PROXY,
ALL_PROXY, NO_PROXY) when AGENT_BROWSER_PROXY is not set.
Fixes #990
* refactor: use typed struct for parse_proxy, fix double Fetch.enable and username-only auth
- Replace serde_json::Value return from parse_proxy with a typed ParsedProxy struct
- Fix double Fetch.enable call when both proxy auth and domain filter are active
(the second call could overwrite handleAuthRequests from the first)
- Allow username-only proxy auth (some proxies don't require a password)
- Handle empty username/password in parse_proxy as None instead of Some("")
- Use install_domain_filter_fetch in auto_launch for consistency
- Update unit tests to use typed struct fields
---------
Co-authored-by: ctate <366502+ctate@users.noreply.github.com>1 parent 23a117c commit cd1f255
7 files changed
Lines changed: 266 additions & 78 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
191 | 193 | | |
192 | 194 | | |
193 | 195 | | |
| |||
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
236 | 244 | | |
237 | 245 | | |
238 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
357 | 365 | | |
358 | 366 | | |
359 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
360 | 370 | | |
361 | 371 | | |
362 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
60 | 70 | | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
64 | 74 | | |
65 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
66 | 80 | | |
67 | 81 | | |
68 | 82 | | |
69 | 83 | | |
70 | 84 | | |
71 | 85 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
78 | 111 | | |
79 | 112 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
85 | 118 | | |
86 | 119 | | |
87 | 120 | | |
| |||
330 | 363 | | |
331 | 364 | | |
332 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
333 | 373 | | |
334 | 374 | | |
335 | 375 | | |
336 | 376 | | |
337 | 377 | | |
338 | 378 | | |
339 | 379 | | |
340 | | - | |
| 380 | + | |
341 | 381 | | |
| 382 | + | |
| 383 | + | |
342 | 384 | | |
343 | 385 | | |
344 | 386 | | |
| |||
694 | 736 | | |
695 | 737 | | |
696 | 738 | | |
697 | | - | |
698 | | - | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
699 | 747 | | |
700 | | - | |
701 | | - | |
702 | | - | |
| 748 | + | |
703 | 749 | | |
704 | 750 | | |
705 | 751 | | |
| |||
1007 | 1053 | | |
1008 | 1054 | | |
1009 | 1055 | | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
1013 | 1059 | | |
1014 | 1060 | | |
1015 | 1061 | | |
1016 | 1062 | | |
1017 | 1063 | | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1021 | 1067 | | |
1022 | 1068 | | |
1023 | 1069 | | |
1024 | 1070 | | |
1025 | 1071 | | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
1029 | 1075 | | |
1030 | 1076 | | |
1031 | 1077 | | |
1032 | 1078 | | |
1033 | 1079 | | |
1034 | | - | |
1035 | | - | |
| 1080 | + | |
| 1081 | + | |
1036 | 1082 | | |
1037 | 1083 | | |
1038 | 1084 | | |
1039 | 1085 | | |
1040 | 1086 | | |
1041 | | - | |
1042 | | - | |
| 1087 | + | |
| 1088 | + | |
1043 | 1089 | | |
1044 | 1090 | | |
1045 | 1091 | | |
1046 | 1092 | | |
1047 | 1093 | | |
1048 | | - | |
1049 | | - | |
1050 | | - | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1051 | 1097 | | |
1052 | 1098 | | |
1053 | 1099 | | |
1054 | 1100 | | |
1055 | 1101 | | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1059 | 1105 | | |
1060 | 1106 | | |
1061 | 1107 | | |
| |||
0 commit comments