Skip to content

[Analyze 2718] Fix wizards shiny source validation - #3017

Open
jerome-ng wants to merge 1 commit into
developfrom
jerome-ng/2718-fix-shinylive-auth-handshake
Open

[Analyze 2718] Fix wizards shiny source validation#3017
jerome-ng wants to merge 1 commit into
developfrom
jerome-ng/2718-fix-shinylive-auth-handshake

Conversation

@jerome-ng

Copy link
Copy Markdown
Collaborator

Summary

ShinyLive runs the dashboard inside a child iframe. The Wizards host previously accepted messages only from the outer iframe, so it rejected the dashboard’s SHINYLIVE_READY event and sent authentication context to the wrong window.

This change:

  • Accepts readiness messages from the outer iframe or its direct dashboard child.
  • Sends AUTH_TOKEN to the exact trusted sender.
  • Validates message origin and source on both the Wizards and Shiny sides.
  • Rejects unrelated same-origin frames.

Related to #2718. Follow-up to #2897.

Copilot AI review requested due to automatic review settings July 29, 2026 08:50
@jerome-ng jerome-ng linked an issue Jul 29, 2026 that may be closed by this pull request
3 tasks
@jerome-ng jerome-ng changed the title Fix wizards shiny source validation [Analyze 2718] Fix wizards shiny source validation Jul 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes postMessage source validation for the Wizards-embedded ShinyLive dashboard so readiness/error events are accepted from the expected frame(s) and auth context is sent back to the correct trusted window.

Changes:

  • Adds a resolver to accept SHINYLIVE_READY from either the outer ShinyLive iframe or its direct dashboard child iframe.
  • Targets AUTH_TOKEN postMessage responses to the exact window that emitted SHINYLIVE_READY, while continuing to validate event.origin.
  • Adds unit tests covering accepted/rejected message-source scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
plugins/ui/apps/wizards/src/utils/shinyDashboardContext.ts Adds resolveShinyDashboardMessageSource to validate/resolve the trusted message sender window.
plugins/ui/apps/wizards/src/utils/tests/shinyDashboardContext.test.ts Adds tests for allowed and rejected message sources (outer iframe, direct child, unrelated/deeper frames).
plugins/ui/apps/wizards/src/components/ShinyDashboardIframe.tsx Uses the resolver to validate message sources and targets AUTH_TOKEN to the readiness sender window.

Comment on lines 90 to 92
} else if (event.data?.type === "SHINYLIVE_ERROR") {
setError("The dashboard reported an error. Please try opening it again.");
}
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.

[Wizard] New Wizard Flow - to go to dashboard pop up directly

3 participants