Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pass tornado_settings command line with a space. #3904

Open
rwmajor2 opened this issue Sep 9, 2018 · 4 comments
Open

Unable to pass tornado_settings command line with a space. #3904

rwmajor2 opened this issue Sep 9, 2018 · 4 comments
Milestone

Comments

@rwmajor2
Copy link

rwmajor2 commented Sep 9, 2018

Trying to do the following:
docker run -it --rm myDockerimg:latest start-notebook.sh --NotebookApp.base_url=/turing/notebooks/f63e305a-539a-4487-b68d-6a147fafb6ee --NotebookApp.token=2VIKxSkcA8o6mEmaIFvQMSO6z1NQOT+txTjWYqk/dv8= --NotebookApp.notebook_dir=/mnt/arcgis --NotebookApp.tornado_settings="{'headers':{'Content-Security-Policy':'frame-ancestors self *.mydomain.com'}}"

I need to launch containers where the CSP could change dynamically, hence why I am not using a config file. However, that space in the tornado_settings is causing me a problem. I have tried numerous attemps of single quotes, double quotes, backslashes, etc. to no avail. Can anyone offer any suggestions?

Looking at the Docker logs, I see Jupyter say this:

Executing the command: jupyter notebook --NotebookApp.base_url=/turing/notebooks/f63e305a-539a-4487-b68d-6a147fafb6ee --NotebookApp.token=2VIKxSkcA8o6mEmaIFvQMSO6z1NQOT+txTjWYqk/dv8= --NotebookApp.notebook_dir=/mnt/arcgis --NotebookApp.tornado_settings={'headers':{'Content-Security-Policy':'frame-ancestors self'}}
The Jupyter HTML Notebook.

This launches a Tornado based HTML Notebook Server that serves up an
HTML5/Javascript Notebook client.

But then complains:

[C 15:56:20.505 NotebookApp] Bad config encountered during initialization:
[C 15:56:20.505 NotebookApp] The 'tornado_settings' trait of a NotebookApp instance must be a dict, but a value of class 'str' (i.e. "{'headers':{'Content-Security-Policy':'frame-ancestors") was specified.
@minrk
Copy link
Member

minrk commented Sep 13, 2018

It's technically possible with the right amount of quotes, but I would consider these settings to effectively require being set in a config file.

@minrk minrk added this to the Reference milestone Sep 13, 2018
@Hotspot0Argus
Copy link

I have this problem too.And how can I fix it?

@vahidke
Copy link

vahidke commented Oct 20, 2020

I've encountered the same issue. Did you figure it out?

@vahidke
Copy link

vahidke commented Oct 21, 2020

So basically you can write this piece of code in your jupyter_config.py:
c.NotebookApp.tornado_settings = {'headers': { 'Content-Security-Policy': "frame-ancestors *YourDomain.com* 'self' ;",}}

However, if you want to do it dynamically through command line, you can write this in your yml file:
command: -c "jupyter lab --NotebookApp.tornado_settings='{\"headers\":{\"Content-Security-Policy\":\"frame-ancestors self *YourDomain.com*; report-uri /api/security/csp-report\"}}'"

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

No branches or pull requests

4 participants