Commit Graph

5482 Commits

Author SHA1 Message Date
Nick Taylor
8d16861eec chore: removed unnecessary comments 2026-02-14 12:26:01 +01:00
Nick Taylor
c9bdce95f6 chore: fixed lint errors 2026-02-14 12:26:01 +01:00
Nick Taylor
7a5404a4b6 chore: formatting 2026-02-14 12:26:01 +01:00
Nick Taylor
c37081e612 feat(gateway): implement trusted-proxy auth logic
- Add 'trusted-proxy' to ResolvedGatewayAuthMode
- Add trustedProxy field to ResolvedGatewayAuth
- Add authorizeTrustedProxy() helper function
- Update authorizeGatewayConnect() to handle trusted-proxy mode
- Validate proxy source IP against trustedProxies list
- Support required headers and user allowlist validation

Part of #1560

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 12:26:01 +01:00
Nick Taylor
f09023cc63 test(gateway): add explicit backward compatibility tests for trusted proxy matching
Added dedicated 'backward compatibility' test suite to verify:
- Exact IP matching still works (no CIDR notation)
- Plain IPs are NOT treated as /32 CIDR (exact match only)
- IPv4-mapped IPv6 normalization preserved (existing normalizeIp behavior)

These tests document that the CIDR matching addition does not break
existing exact-IP configurations and preserves all previous behavior.
2026-02-14 12:26:01 +01:00
Nick Taylor
0ccce67e9f fix(gateway): add CIDR subnet matching for trusted proxies
The isTrustedProxyAddress() function was doing exact IP matching only,
which broke when trustedProxies contained CIDR notation (e.g., '10.42.0.1/24').

Issue: Pomerium connecting from 10.42.0.59 was rejected even though
trustedProxies contained '10.42.0.1/24'.

Root cause: The function used normalizeIp() comparison which stripped
the /24 suffix and compared '10.42.0.1' === '10.42.0.59' (false).

Fix:
- Added ipMatchesCIDR() helper for IPv4 CIDR matching using bit masks
- Updated isTrustedProxyAddress() to check CIDR blocks when proxy
  contains '/' character, otherwise exact IP match
- Supports /0 through /32 prefix lengths
- Validates IP and prefix length format

Tests:
- Exact IP matching (existing behavior)
- CIDR /24, /16, /32 subnet matching
- Mixed exact IPs and CIDR notation in same array
- Edge cases (undefined, empty, invalid CIDR)

This was the ACTUAL bug preventing Docker deployment with Pomerium.
The entrypoint correctly detected and configured trustedProxies with
CIDR notation, but the gateway rejected connections due to this bug.
2026-02-14 12:26:01 +01:00
Nick Taylor
c7871813a7 docs(test): document that runtime config tests cover both validation layers
Added comment to clarify that the lan binding + trusted-proxy test
validates both:
1. CLI startup validation (src/cli/gateway-cli/run.ts line 246)
2. Runtime config validation (src/gateway/server-runtime-config.ts line 99)

Both layers must allow lan binding with trusted-proxy auth mode.
The runtime config test implicitly validates both code paths since
they use the same logic (checking for shared secret).
2026-02-14 12:26:01 +01:00
Nick Taylor
57ae179bbc fix(gateway-cli): allow lan binding with trusted-proxy in CLI startup
There were TWO validations for lan binding without auth:
1. src/gateway/server-runtime-config.ts (FIXED in 563052d)
2. src/cli/gateway-cli/run.ts (THIS FIX)

The CLI startup validation was rejecting lan binding when using
trusted-proxy auth mode because it only checked for token/password.

This is the ACTUAL bug causing the crash loop - the CLI validation
runs before the runtime config validation, so it was failing first.

Fix: Add && resolvedAuthMode !== 'trusted-proxy' to the CLI check
on line 246, matching the fix in server-runtime-config.ts.
2026-02-14 12:26:01 +01:00
Nick Taylor
a9f7069060 test(browser): add tests for trusted-proxy auto-token prevention
Add tests to verify that browser control auth doesn't auto-generate
tokens when gateway.auth.mode is 'trusted-proxy' or 'password'.

Covers:
- Trusted-proxy mode: no token generation
- Password mode: no token generation (even if password unset)
- Token mode: respects existing token
- Test environment: skips auto-generation
2026-02-14 12:26:01 +01:00
Nick Taylor
267ff35e57 fix(browser): prevent auto-token generation from overwriting trusted-proxy auth
The browser control service was auto-generating a gateway.auth.token when
no token/password was detected, even when gateway.auth.mode was set to
'trusted-proxy'. This overwrote the trusted-proxy configuration and
switched the gateway back to token mode.

Fix: Skip auto-token generation when auth mode is 'trusted-proxy',
similar to how it already skips for 'password' mode.

This prevents the browser service from mangling the trusted-proxy config
during startup.
2026-02-14 12:26:01 +01:00
Nick Taylor
befb4d59a8 test(gateway): add tests for trusted-proxy lan binding validation
Add comprehensive tests for gateway runtime config validation:
- Trusted-proxy mode allows lan binding
- Trusted-proxy mode rejects loopback binding
- Trusted-proxy mode requires trustedProxies configured
- Token mode requires token to be set
- Token mode allows lan binding when token is provided

These tests validate the fix for the lan binding validation bug
and prevent regression.
2026-02-14 12:26:01 +01:00
Nick Taylor
702cf6545b fix(gateway): allow lan binding with trusted-proxy auth mode
Critical bug: Gateway startup validation rejected lan binding when using
trusted-proxy auth mode because it only checked for token/password.

The validation on line 99 threw 'refusing to bind gateway to lan without auth'
even when authMode was 'trusted-proxy', because hasSharedSecret is false
for trusted-proxy mode (it doesn't use tokens/passwords).

Fix: Allow lan binding when authMode is 'trusted-proxy' by adding
&& authMode !== 'trusted-proxy' to the condition.

This allows the gateway to start with bind=lan when configured for
trusted-proxy authentication (e.g., behind Pomerium).

Without this fix, users get crash-loop with 'refusing to bind' error
even though trusted-proxy mode is correctly configured.
2026-02-14 12:26:01 +01:00
Nick Taylor
d23d26e0b5 feat(ui): hide token/password fields when gateway is in trusted-proxy mode
- Add authMode to gateway snapshot schema (protocol)
- Resolve and expose auth mode in buildGatewaySnapshot()
- Update Control UI overview to conditionally render based on authMode
- When authMode is 'trusted-proxy':
  - Hide Gateway Token field
  - Hide Password field
  - Show informational callout explaining trusted-proxy auth
  - Display auth mode and clarify no token needed
- When authMode is 'token', 'password', or 'none':
  - Show token and password fields as before (unchanged UX)

Benefits:
- Clearer UX: users won't be confused trying to enter tokens
- Security clarity: makes it obvious proxy handles auth
- Better feedback: explains what trusted-proxy mode means

UI shows:
'This gateway is configured for trusted-proxy auth mode.
User identity is managed by your reverse proxy (Pomerium, Caddy, Traefik, etc.).
Auth Mode: trusted-proxy
No gateway token required — authentication handled by proxy'
2026-02-14 12:26:01 +01:00
Nick Taylor
1fc97ebe23 test(cli): add tests for trusted-proxy auth configuration
- Add tests for buildGatewayAuthConfig with trusted-proxy mode
- Test all trusted-proxy options (userHeader, requiredHeaders, allowUsers)
- Test minimal trusted-proxy config (userHeader only)
- Test preserving allowTailscale when switching to trusted-proxy
- Test error when trustedProxy config missing
- Test dropping token/password when switching to trusted-proxy
- Add integration tests for interactive gateway prompting flow
- Test trusted-proxy with all options and with minimal options

Test coverage:
- 5 new tests in configure.gateway-auth.test.ts
- 2 new tests in configure.gateway.test.ts

All tests verify proper handling of the new trusted-proxy auth mode.
2026-02-14 12:26:01 +01:00
Nick Taylor
e1ce11c4b7 feat(cli): add trusted-proxy auth mode to gateway configuration
- Add 'trusted-proxy' option to gateway auth mode selection
- Prompt for trusted-proxy config: userHeader, requiredHeaders, allowUsers
- Prompt for trustedProxies IP list (required for trusted-proxy mode)
- Update buildGatewayAuthConfig to handle trusted-proxy mode
- Add helpful note explaining trusted-proxy use cases and docs link

Enables CLI configuration of trusted-proxy auth during:
- Initial onboarding (openclaw onboard)
- Gateway configuration (openclaw configure)

Example prompts:
- User identity header: x-forwarded-user (default)
- Required headers: x-forwarded-proto,x-forwarded-host (optional)
- Allowed users: nick@example.com,admin@company.com (optional)
- Trusted proxy IPs: 10.0.1.10,192.168.1.5 (required)

Refs: feat/trusted-proxy auth implementation
2026-02-14 12:26:01 +01:00
Nick Taylor
097a2f5bd1 test(security): add trusted-proxy audit tests
- Test trusted-proxy mode flagged as critical
- Test missing trustedProxies finding
- Test missing userHeader finding
- Test empty allowUsers warning
- Fix env isolation for bind_no_auth test

Part of #1560

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 12:26:01 +01:00
Nick Taylor
b4f6e26ae9 test(gateway): add trusted-proxy auth tests
- Test valid request from trusted proxy
- Test rejection of untrusted source
- Test missing user header handling
- Test missing required headers
- Test user allowlist enforcement
- Test Pomerium-style headers
- Test whitespace trimming

Part of #1560

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 12:26:01 +01:00
Nick Taylor
47de0ce1db feat(security): add audit findings for trusted-proxy mode
- Add critical finding when trusted-proxy auth is enabled
- Flag missing trustedProxies configuration
- Flag missing userHeader configuration
- Warn when allowUsers is empty (allows any authenticated user)

Part of #1560

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 12:26:01 +01:00
Nick Taylor
711fb49a98 feat(gateway): update runtime config guard for trusted-proxy
- Allow non-loopback bind with trusted-proxy auth mode
- Reject trusted-proxy + loopback combination (nonsensical)
- Require trustedProxies to be configured for trusted-proxy mode

Part of #1560

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 12:26:01 +01:00
Nick Taylor
f3ec913489 feat(gateway): add trusted-proxy auth mode types and schema
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 12:26:01 +01:00
Peter Steinberger
6182d3ef85 test: increase live-model retry token budget for reasoning-first providers 2026-02-14 12:23:51 +01:00
Pejman Pour-Moezzi
9475791d98 fix: update remaining replyToMode "first" defaults to "off"
- src/channels/dock.ts: core channel dock fallback
- src/auto-reply/reply/reply-routing.test.ts: test expectation
- docs/zh-CN/channels/telegram.md: Chinese docs reference

Comprehensive grep confirms no remaining Telegram-specific "first"
defaults after this commit.
2026-02-13 23:31:17 -08:00
Pejman Pour-Moezzi
ad96c126ed fix(telegram): change default replyToMode from "first" to "off"
In 2026.2.13, the combination of implicit reply threading (#14976) and
the existing Telegram default replyToMode="first" causes every bot
response in DMs to be sent as a native Telegram reply (quoted message
bubble), even for simple exchanges like "Hi" → "Hey".

This is a UX regression: prior to 2026.2.13, reply threading was less
consistent so the "first" default rarely produced visible quote bubbles
in DMs. Now that implicit threading works reliably, the default
effectively means every first message in a response gets quoted —
which feels noisy and unexpected in 1:1 conversations.

Changing the default to "off" restores the pre-2026.2.13 DM experience.
Users who want reply threading can still opt in via config:

  channels.telegram.replyToMode: "first" | "all"

Tested by toggling replyToMode on a live 2026.2.13 instance:
- replyToMode="first" → every response quotes the user message
- replyToMode="off" → clean responses without quote bubbles

No test changes needed: existing tests explicitly set replyToMode
rather than relying on the default.
2026-02-13 23:31:17 -08:00
vignesh07
e38ed4f640 fix(memory): default qmd searchMode to search + scope search/vsearch to collections 2026-02-13 23:14:34 -08:00
Peter Steinberger
a50638eead perf(test): disable vector index in OpenAI batch tests 2026-02-14 05:25:40 +00:00
Peter Steinberger
0e5e72edb4 perf(test): shrink memory embedding batch fixtures 2026-02-14 05:25:40 +00:00
Peter Steinberger
98bb4225fd perf(test): minimize gateway startup in vitest 2026-02-14 05:25:40 +00:00
Peter Steinberger
d8beddc8b7 refactor(onboard): unify auth-choice aliases and provider flags 2026-02-14 05:58:26 +01:00
Peter Steinberger
2f4cef2021 perf(test): remove last-route polling in partial reply gating 2026-02-14 04:57:28 +00:00
Peter Steinberger
4335668d28 chore(test): fix cron every-jobs-fire unused import 2026-02-14 04:57:28 +00:00
Peter Steinberger
e6d5b5fb11 perf(test): remove slow port inspection and reconnect sleeps 2026-02-14 04:57:28 +00:00
Peter Steinberger
eab9dc538a refactor(onboard): unify auth-choice catalog for CLI help 2026-02-14 05:51:17 +01:00
Peter Steinberger
fdda261478 fix: align NVIDIA provider docs and model ids (#11606) 2026-02-14 05:48:40 +01:00
Gabriel
e0132514f6 fix: needed to use format:fix 2026-02-14 05:48:40 +01:00
Gabriel
3feb5d1f10 fix: LINT AGAIN 2026-02-14 05:48:40 +01:00
Gabriel
f90a39e984 fix: my mistakes 2026-02-14 05:48:40 +01:00
Gabriel
8f2884b986 fix: i am fixing all the changes that claude made. vibe coding is not there yet. anyways, i fixed the issues that the bot told me to fix 2026-02-14 05:48:40 +01:00
anthropic-code-agent[bot]
c640b5f86c feat: add NVIDIA API provider integration
Add support for NVIDIA's API (https://integrate.api.nvidia.com/v1) with three models:
- nvidia/llama-3.1-nemotron-70b-instruct (default)
- nvidia/llama-3.3-70b-instruct
- nvidia/mistral-nemo-minitron-8b-8k-instruct

Users can configure via NVIDIA_API_KEY environment variable or auth profiles.

Co-authored-by: thesomewhatyou <162917831+thesomewhatyou@users.noreply.github.com>
2026-02-14 05:48:40 +01:00
Peter Steinberger
2d4d32cb2d test(cron): await persistence before temp cleanup 2026-02-14 03:18:27 +00:00
青雲
89fa93ed75 feat: support freshness parameter for Perplexity web_search provider (#15343)
Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 01aba2bfba
Co-authored-by: echoVic <16428813+echoVic@users.noreply.github.com>
Co-authored-by: sebslight <19554889+sebslight@users.noreply.github.com>
Reviewed-by: @sebslight
2026-02-13 22:18:16 -05:00
Peter Steinberger
7f227fc8cc perf(test): avoid heavy browser barrels in pw-ai tests 2026-02-14 03:13:32 +00:00
Peter Steinberger
115444b37c perf(test): deflake and speed up qmd manager tests 2026-02-14 03:08:13 +00:00
Peter Steinberger
9126930363 test(cron): remove flaky real-timer polling 2026-02-14 03:00:06 +00:00
Peter Steinberger
72e9364bac perf(test): speed up hot test files 2026-02-14 02:55:39 +00:00
Peter Steinberger
dd08ca97bb perf(test): reduce import and fixture overhead in hot tests 2026-02-14 02:49:19 +00:00
Peter Steinberger
2583de5305 refactor(routing): normalize binding matching and harden qmd boot-update tests 2026-02-14 03:40:28 +01:00
Peter Steinberger
36726b52f4 perf(test): drop redundant memory reindex integration case 2026-02-14 02:37:09 +00:00
Peter Steinberger
3871b5a238 perf(test): remove dead telegram bot test scaffolding 2026-02-14 02:37:09 +00:00
Peter Steinberger
63711330e4 perf(test): dedupe browser/telegram coverage and trim batch retry cost 2026-02-14 02:37:09 +00:00
Peter Steinberger
d3eb014892 perf(test): dedupe telegram/node coverage and speed fixtures 2026-02-14 02:37:09 +00:00