feat: machine-id firewall header — bundled mesh core (Host fix) + openframe-client - #1688
feat: machine-id firewall header — bundled mesh core (Host fix) + openframe-client#1688mikhailm-coder wants to merge 7 commits into
Conversation
…ine-id headers Refreshes the ARTIFACTORY-served CoreModule.js snapshot from the meshagent hotfix/machine-id-header branch: in openFrameMode the core now stamps x-machine-id (read from the shared OpenFrame machine_id file) and an Authorization bearer token on tunnel, download, and self-update requests. On agent binaries that predate the openFrameMode JS property the new code is a silent no-op, so the core can roll out ahead of the binaries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughOpenFrame support adds conditional machine ID, bearer authorization, and host headers to outbound HTTP and WebSocket requests. The changes cover tunnels, downloads, file transfers, console connections, and agent self-updates. Tunnel diagnostic logging and minor formatting artifacts were removed. ChangesOpenFrame request headers
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sync the ARTIFACTORY-served CoreModule.js with meshagent: addOpenFrameHeaders now restores the Host header the duktape http client drops once a headers object is present, so openFrame-mode relay/tunnel/download dials reach the gateway instead of getting rejected host-less. Fixes remote sessions stuck "connecting" on the 0.1.0 mesh binary — served to installed agents with no binary rebuild. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openframe-client-core/src/main/resources/meshcentral-core-module`:
- Around line 1049-1052: Update the token injection block to require both
mesh.openFrameMode and a truthy result from mesh.authToken() before appending
the authorization query parameter. Preserve the existing separator handling, and
URL-encode the token value before adding it so null, undefined, and empty tokens
are never sent.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ea83797b-82db-48e5-a819-c97ea6acfdab
📒 Files selected for processing (1)
openframe-client-core/src/main/resources/meshcentral-core-module
| // Inject Openframe JWT token | ||
| console.log("Inject Openframe JWT token") | ||
| var token = mesh.authToken(); | ||
| var separator = path.indexOf('?') !== -1 ? '&' : '?'; | ||
| url += separator + 'authorization=' + mesh.authToken(); | ||
| url += separator + 'authorization=' + token; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Trace token availability checks and authorization query handling.
rg -n -C 4 '\bauthToken\s*\(|\bopenFrameMode\b|authorization' \
openframe-client-core/src/main/resources/meshcentral-core-module \
openframe-gateway-service-coreRepository: flamingo-stack/openframe-oss-lib
Length of output: 10546
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- candidate function and surrounding code ---'
cat -n openframe-client-core/src/main/resources/meshcentral-core-module | sed -n '720,770p;1028,1060p'
printf '%s\n' '--- authToken and openFrameMode definitions/usages ---'
rg -n -C 6 'authToken\s*=|authToken\s*[:(]|openFrameMode\s*=|openFrameMode\s*:' \
--glob '!**/node_modules/**' .
printf '%s\n' '--- gateway authentication filter and entry point ---'
cat -n openframe-gateway-service-core/src/main/java/com/openframe/gateway/security/filter/AddAuthorizationHeaderFilter.java | sed -n '1,140p'
cat -n openframe-gateway-service-core/src/main/java/com/openframe/gateway/security/WsAwareAuthenticationEntryPoint.java | sed -n '65,110p'Repository: flamingo-stack/openframe-oss-lib
Length of output: 13201
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path("openframe-client-core/src/main/resources/meshcentral-core-module")
text = p.read_text()
for needle in ("function getServerTargetUrl", "authToken", "openFrameMode"):
print(f"--- occurrences of {needle!r} ---")
for i, line in enumerate(text.splitlines(), 1):
if needle in line:
print(i, line)
PYRepository: flamingo-stack/openframe-oss-lib
Length of output: 610
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- getServerTargetUrl call sites ---'
rg -n -C 5 'getServerTargetUrl(?:Ex)?\s*\(' \
openframe-client-core/src/main/resources/meshcentral-core-module
printf '%s\n' '--- mesh API references and related documentation ---'
rg -n -i -C 3 'authToken|openFrameMode|OpenFrame.*token|token.*OpenFrame' \
--glob '!**/node_modules/**' \
--glob '!openframe-client-core/src/main/resources/meshcentral-core-module' \
.
printf '%s\n' '--- JavaScript coercion and URL separator probe ---'
node - <<'JS'
for (const token of [null, undefined, '', 'jwt']) {
const path = 'download?part=1';
const url = 'https://host/ws/tools/agent/meshcentral-server/' + path;
const separator = path.indexOf('?') !== -1 ? '&' : '?';
console.log(JSON.stringify({ token, result: url + separator + 'authorization=' + token }));
}
JSRepository: flamingo-stack/openframe-oss-lib
Length of output: 36749
Append authorization only for a non-empty OpenFrame token.
The current code converts null or undefined to text and the gateway can create Authorization: Bearer null or Bearer undefined when other token sources are absent. Guard mesh.openFrameMode and mesh.authToken, append only a truthy token, and URL-encode it. The gateway checks cookies and the alternate header before the query parameter.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@openframe-client-core/src/main/resources/meshcentral-core-module` around
lines 1049 - 1052, Update the token injection block to require both
mesh.openFrameMode and a truthy result from mesh.authToken() before appending
the authorization query parameter. Preserve the existing separator handling, and
URL-encode the token value before adding it so null, undefined, and empty tokens
are never sent.
…connections Port of the machine-id-header client work from openframe-oss-tenant (hotfix/machine-id-header). MachineIdService persists a locally generated UUID in the shared app-support dir (read by mesh/fleet tool agents) and stamps it as x-machine-id on the HTTP clients, the NATS connection, and the NATS log stream (replacing the openframe-client placeholder). The server-assigned machine_id still names the NATS connection. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The oss-lib side of the machine-id firewall-header work, combining the mesh core and client changes (folds in the former #1729).
Mesh core (
openframe-client-core/src/main/resources/meshcentral-core-module)CoreModule.js: in OpenFrame mode the served core stampsx-machine-id(+ Authorization) on tunnel/download/self-update requests.96954f407):addOpenFrameHeadersnow setsHost, fixing the Remote Desktop relay regression the 0.1.0 mesh binary otherwise triggers (a duktape-http quirk drops Host onceoptions.headersexists). Verified working live.Client (
clients/openframe-client/)MachineIdService: generates a localUuid::v4(), persists it to the shared app-supportmachine_idfile (read by the mesh/fleet tool agents), cached behindArc<RwLock>.x-machine-idon the HTTP clients, the NATS control connection, and the NATS log stream (replacing the"openframe-client"placeholder). Server-assignedmachine_idstill names the NATS connection.openframe-agent-lib.cargo check --features bin+cargo fmt --checkpass. Companion PRs: meshagent #78, fleetmdm #96.🤖 Generated with Claude Code