feat: expose selected JSON-RPC methods over authenticated HTTP - #1515
Open
nitishagar wants to merge 1 commit into
Open
feat: expose selected JSON-RPC methods over authenticated HTTP#1515nitishagar wants to merge 1 commit into
nitishagar wants to merge 1 commit into
Conversation
Add POST /rpc/:method under the existing protected (local-auth) route group, dispatching an opt-in allowlist of methods (getTLSState, setTLSState, getNetworkSettings, setNetworkSettings, getDeviceID) through the same callRPCHandler path the WebRTC data channel uses. This lets scripts drive device config over plain HTTP without a browser, reusing the existing cookie auth. Non-allowlisted methods return 404, unauthenticated requests 401, malformed JSON 400, and handler errors or panics 500 (panic recovery is inherited from callRPCHandler). Additive only: no existing route or handler changes. Closes jetkvm#1320
nitishagar
marked this pull request as ready for review
July 2, 2026 08:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Exposes a reviewed subset of JSON-RPC methods over an authenticated HTTP endpoint, so scripts and automation can drive device configuration (TLS, network, device ID) without a browser/WebRTC data channel.
Closes #1320
Change
POST /rpc/:methodroute registered inside the existingprotectedgroup, so it inherits the current local-auth cookie check (no new auth scheme).handleRPCDispatchlooks the method up in an opt-in allowlist (httpExposedRPC:getTLSState,setTLSState,getNetworkSettings,setNetworkSettings,getDeviceID), binds an optional JSON body tomap[string]any, and dispatches through the samecallRPCHandlerpath the WebRTC transport uses — so semantics (including panic recovery) are identical.Behavior
rpcHandlers,callRPCHandler,RPCHandler, or any existing route.Not doing
No new token scheme, no blanket exposure of all RPC methods, no resource-oriented REST verbs, no client SDK.
Testing
web_test.go(httptest againstsetupRouter()): 401 unauth, 404 non-allowlisted, result-shape forgetDeviceID/getTLSState, 400 malformed JSON, error→500, and a real panic→500 verifying recovery is wired through the HTTP path. Follows the existing//go:build linux && armconvention forkvm-package tests (runs in the on-device test build).curl -X POSTwith a validauthTokencookie returns the method result; without it, 401.