Skip to content

[HOTFIX] Require authenticated tokens for terminal WebSocket connections - #5639

Open
jongyoul wants to merge 2 commits into
apache:masterfrom
jongyoul:codex/authenticate-terminal-websocket
Open

jongyoul wants to merge 2 commits into
apache:masterfrom
jongyoul:codex/authenticate-terminal-websocket

Conversation

@jongyoul

Copy link
Copy Markdown
Member

This associates terminal WebSocket connections with the paragraph execution that created them.

  • Issues a scoped session proof for terminal execution
  • Passes the proof through the REST and frontend flow
  • Validates the proof before establishing the terminal connection
  • Keeps terminal lifecycle state isolated per execution
  • Adds backend, classic UI, and Angular regression coverage

The core, quick, and frontend workflows provide the full validation.

Copilot AI balanced review requested due to automatic review settings November 29, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Normal terminal loads never open a WebSocket because the iframe omits the authorization request, and shared personalized executions can invalidate another user's pending challenge.

2 open issues
What changed in this PR

Reworks Apache Zeppelin’s terminal authorization to bind shell access to a paragraph execution instead of a shared terminal-server token.

Changes:

  • Adds execution-specific keys, scoped proofs, and a permission-checked REST endpoint.
  • Connects classic and Angular result views to the terminal authorization flow.
  • Adds single-use challenge validation, lifecycle updates, and regression coverage.
File Description
zeppelin-web/​src/​app/​notebook/​paragraph/​result/​result.controller.test.js Tests classic UI proof relaying and cleanup.
zeppelin-web/​src/​app/​notebook/​paragraph/​result/​result.controller.js Adds iframe validation and proof relaying.
zeppelin-web-angular/​src/​app/​services/​notebook.service.ts Adds the terminal-proof REST request.
zeppelin-web-angular/​src/​app/​pages/​workspace/​share/​result/​result.component.ts Adds Angular iframe authorization handling.
zeppelin-web-angular/​src/​app/​pages/​workspace/​share/​result/​result.component.spec.ts Tests origin checks and detached-frame handling.
zeppelin-web-angular/​src/​app/​pages/​workspace/​published/​paragraph/​paragraph.component.html Passes note identity to published results.
zeppelin-web-angular/​src/​app/​pages/​workspace/​notebook/​paragraph/​paragraph.component.html Passes note identity to notebook results.
zeppelin-server/​src/​test/​java/​org/​apache/​zeppelin/​rest/​NotebookSecurityRestApiTest.java Tests permissions and personalized execution proofs.
zeppelin-server/​src/​main/​java/​org/​apache/​zeppelin/​rest/​NotebookRestApi.java Adds permission-checked terminal-proof issuance.
zeppelin-server/​src/​main/​java/​org/​apache/​zeppelin/​rest/​message/​TerminalAuthorizationRequest.java Defines the challenge request payload.
zeppelin-server/​src/​main/​java/​org/​apache/​zeppelin/​notebook/​Paragraph.java Creates and retains terminal execution authentication.
zeppelin-interpreter/​src/​test/​java/​org/​apache/​zeppelin/​user/​SessionProofTest.java Tests proof generation and context binding.
zeppelin-interpreter/​src/​main/​java/​org/​apache/​zeppelin/​user/​SessionProof.java Implements random keys and scoped cryptographic proofs.
zeppelin-interpreter/​src/​main/​java/​org/​apache/​zeppelin/​user/​AuthenticationInfo.java Carries execution keys and supports authentication copying.
shell/​src/​test/​java/​org/​apache/​zeppelin/​shell/​TerminalInterpreterTest.java Updates terminal connection and authentication tests.
shell/​src/​test/​java/​org/​apache/​zeppelin/​shell/​terminal/​TerminalSocketTest.java Makes received-message storage thread-safe.
shell/​src/​test/​java/​org/​apache/​zeppelin/​shell/​terminal/​TerminalAuthorizationRegistryTest.java Tests challenge scope, expiry, replacement, and concurrent claims.
shell/​src/​main/​resources/​ui_templates/​terminal-dashboard.jinja Marks terminal iframes for authorization relays.
shell/​src/​main/​resources/​html/​js/​index.js Handles proof responses before opening the WebSocket.
shell/​src/​main/​java/​org/​apache/​zeppelin/​shell/​TerminalInterpreter.java Issues execution-bound challenges and updates listener lifecycle.
shell/​src/​main/​java/​org/​apache/​zeppelin/​shell/​terminal/​websocket/​TerminalSocket.java Validates proofs before starting shell sessions.
shell/​src/​main/​java/​org/​apache/​zeppelin/​shell/​terminal/​TerminalThread.java Owns the challenge registry and coordinates startup.
shell/​src/​main/​java/​org/​apache/​zeppelin/​shell/​terminal/​TerminalSession.java Moves idle-timeout ownership to the socket handler.
shell/​src/​main/​java/​org/​apache/​zeppelin/​shell/​terminal/​TerminalManager.java Makes context storage concurrent and tightens cleanup matching.
shell/​src/​main/​java/​org/​apache/​zeppelin/​shell/​terminal/​TerminalAuthorizationRegistry.java Implements expiring, single-use terminal challenges.

Review effort: Balanced

// be used to give control of the terminal to something else. When that
// thing is complete, should call io.pop() to restore control to the
// previous io object.
};
Comment on lines +58 to +61
String terminalId = formatId(noteId, paragraphId);
String previousChallengeDigest = terminalIdToChallengeDigest.remove(terminalId);
if (previousChallengeDigest != null) {
pendingAuthorizations.remove(previousChallengeDigest);
Emit bounded authorization requests when the terminal iframe initializes.

Scope pending challenges by execution owner and add focused regressions.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants