nebari-dev / nebari

🪴 Nebari - your open source data science platform
https://nebari.dev
BSD 3-Clause "New" or "Revised" License
275 stars 88 forks source link

[BUG] - Panel Preview is blocked #2580

Closed kcpevey closed 2 weeks ago

kcpevey commented 1 month ago

Describe the bug

Breaking this out from this issue comment.

Panel Preview has worked for me in the past, but with our current (nebari 2024.7.1) version of JHub/JLab, this extension no longer works.

For reference, I originally asked about this on the holoviz discourse.

Expected behavior

You can preview a panel object in the notebook:

image

However, Panel Preview allows you to view what it would look like deployed. This is particularly helpful when developing apps which include templates since they won't render in the notebook context AND for deployed apps, any errors which may arise during the deployment process can be surfaced here, in the notebook, where it can be immediately modified.

This is particularly important in the context of Nebari since getting to the logs for app deployment is tedious and not well documented. Being able to work through deployment bugs before moving to the App Launcher interface would greatly improve usability.

OS and architecture in which you are running Nebari

Linux AWS

How to Reproduce the problem?

Environment:

channels:
  - conda-forge
dependencies:
  - python=3.10
  - panel
  - param
  - ipykernel

In a notebook:

import panel as pn

pn.extension()

pn.Row(pn.pane.Markdown("Some text")).servable()

Command output

The preview pane itself is showing nebari.quansight.dev refused to connect. and the js console is showing the error: Refused to frame 'https://nebari.quansight.dev/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'none'".

Versions and dependencies used.

No response

Compute environment

None

Integrations

No response

Anything else?

From @krassowski in the original discussion:

JupyterHub 4.1 introduced pretty restrictive CSP. In principle we can change CSP with c.JupyterHub.tornado_settings traitlet.

For reference:

Here is a related upstream issue:

Quoting:

This is required for inter-user security on single-domain deployments, but can be safely disabled with per-user subdomains.

Nebari should implement per-user domains and then all these restrictions can be safely lifted.

dharhas commented 1 month ago

@krassowski is there any way for the panel preview to work without relaxing the CSP or enabling per-user domains. i.e. is there anything we can do with upstream changes to the preview button implementation

krassowski commented 1 month ago

Yes. I opened an upstream issue in https://github.com/holoviz/panel/issues/7039 and will open two PRs to implement changes required.