fix: Distributed API auth hardening — Bearer tokens and URL normalization

- Extend WS upgrade handler to accept Authorization: Bearer tokens as a
  fallback to cookie auth. Remote Sencho instances receive proxied WS
  connections carrying Bearer (no cookie), so the previous cookie-only
  check caused immediate 401 rejections for all proxied log/terminal streams.
- Log token validation failures in authMiddleware (was silently swallowed,
  violating no-empty-catch directive).
- Normalize api_url by stripping trailing slashes in testRemoteConnection,
  the HTTP proxy target, and the WS proxy target to prevent double-slash URLs.
This commit is contained in:
SaelixCode
2026-03-19 15:11:57 -04:00
parent 67c7078128
commit 5932bced36
3 changed files with 13 additions and 5 deletions
+2 -1
View File
@@ -154,7 +154,8 @@ export class NodeRegistry {
}
try {
const response = await axios.get(`${node.api_url}/api/auth/check`, {
const baseUrl = node.api_url.replace(/\/$/, '');
const response = await axios.get(`${baseUrl}/api/auth/check`, {
headers: { Authorization: `Bearer ${node.api_token}` },
timeout: 8000,
});