#17378: fix(gateway): allow dangerouslyDisableDeviceAuth with trusted-proxy auth mode
gateway
size: XS
Cluster:
Device Auth and Security Fixes
## Summary
Fixes #8529
Control UI settings dangerouslyDisableDeviceAuth and allowInsecureAuth did not work when using trusted-proxy authentication. Previously, these options only applied to token or password authentication modes.
This PR updates the authentication logic so that Control UI bypass settings are honored for authenticated trusted-proxy connections.
## Changes
- Modified `src/gateway/server/ws-connection/message-handler.ts` to allow `allowControlUiBypass` to work with authenticated trusted-proxy connections
- Added test case in `src/gateway/server.auth.e2e.test.ts` to verify the fix
## Root Cause
In `message-handler.ts`, `canSkipDevice` only checked `sharedAuthOk` (which is only true for token/password auth), but didn't consider the `allowControlUiBypass` settings for trusted-proxy auth.
**Before:**
```typescript
const canSkipDevice = sharedAuthOk;
```
**After:**
```typescript
const canSkipDevice = sharedAuthOk || (allowControlUiBypass && authOk);
```
## Impact
This allows Control UI to skip device pairing when:
- dangerouslyDisableDeviceAuth is enabled, AND
- The user is authenticated via trusted-proxy
This is particularly useful for setups using identity-aware reverse proxies (nginx + oauth2-proxy, Pomerium, Caddy + OAuth, etc.) where device pairing adds unnecessary friction.
## Testing
Added e2e test: allows control ui without device identity with trusted-proxy auth when device auth is disabled
Configuration Example
With this fix, the following configuration now works as expected:
`Replace trustedProxies with your proxy IP`
````typescript
{
"gateway": {
"bind": "lan",
"trustedProxies": ["192.168.1.226"],
"controlUi": {
"dangerouslyDisableDeviceAuth": true
},
"auth": {
"mode": "trusted-proxy",
"trustedProxy": {
"userHeader": "x-forwarded-user"
}
}
}
}
````
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes Control UI device authentication bypass for trusted-proxy auth mode. Previously, `dangerouslyDisableDeviceAuth` and `allowInsecureAuth` settings only applied to token/password authentication, leaving trusted-proxy users unable to skip device pairing despite explicit configuration.
**Key changes:**
- Updated `canSkipDevice` logic in `message-handler.ts:434` to honor `allowControlUiBypass` for any authenticated connection, not just shared-secret auth
- Added e2e test verifying the fix works for `dangerouslyDisableDeviceAuth` with trusted-proxy auth
The fix correctly checks that both `allowControlUiBypass` is enabled (meaning the user explicitly configured bypass settings) AND `authOk` is true (meaning the user is authenticated via trusted-proxy).
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no risks identified
- The fix is minimal, focused, and correct. It extends existing bypass logic to cover trusted-proxy auth without introducing security issues. The change maintains all security checks (still requires successful authentication and explicit bypass configuration), and adds appropriate test coverage.
- No files require special attention
<sub>Last reviewed commit: b8fc950</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#17705: fix(gateway): allow trusted-proxy auth to bypass device-pairing gates
by dashed · 2026-02-16
89.6%
#17572: fix: make dangerouslyDisableDeviceAuth bypass device identity checks
by gitwithuli · 2026-02-15
85.9%
#17605: fix: preserve scopes when disableControlUiDeviceAuth is enabled
by MisterGuy420 · 2026-02-16
84.7%
#20089: fix(gateway): preserve control-ui scopes when dangerouslyDisableDev...
by vashkartik · 2026-02-18
84.7%
#19389: Fix #2248: Allow insecure auth bypass when device signature validat...
by cedillarack · 2026-02-17
84.4%
#20422: Fix/tailscale device pairing
by slagyr · 2026-02-18
82.8%
#16310: fix(ws-connection): skip device pairing when client authenticates w...
by nawinsharma · 2026-02-14
82.0%
#23280: fix(control-ui): remove stale allowInsecureAuth suggestion from err...
by anillBhoi · 2026-02-22
82.0%
#15722: fix: prefer explicit token over stored device token for remote gate...
by 0xPotatoofdoom · 2026-02-13
79.5%
#23364: Gateway: add risk-ack interlock for dangerous Control UI flags
by bmendonca3 · 2026-02-22
79.0%