Hope all is well! I am having issues setting up JupyterHub in an iframe. This was posted as a GitHub issue, per the guidance I am posting here for ideas/discussion =).
When I configure the ‘Content-Security-Policy’ setting the login process does not complete.
How to reproduce:
1.) Set Content-Security-Policy in jupyterhub_config.py
c.JupyterHub.tornado_settings = {'headers': {'Content-Security-Policy': "frame-ancestors 10.200.50.3:80 "}}
**I have tried multiple variants of the Content-Security-Policy setting with the same results.
2.) Authenticate
Expected Result:
Launch hub
Result:
Redirected to login page
Other:
If I comment out c.JupyterHub.tornado_settings I am redirected to hub after authentication as expected.
Logs:
With c.JupyterHub.tornado_settings enabled
[D 2020-08-05 21:54:16.821 JupyterHub base:522] Setting cookie jupyterhub-session-id: {'httponly': True}
[D 2020-08-05 21:54:16.822 JupyterHub base:526] Setting cookie for bob: jupyterhub-hub-login
[D 2020-08-05 21:54:16.822 JupyterHub base:522] Setting cookie jupyterhub-hub-login: {'httponly': True, 'path': '/hub/'}
[I 2020-08-05 21:54:16.822 JupyterHub base:707] User logged in: bob
[D 2020-08-05 21:54:16.822 JupyterHub user:242] Creating <class 'sudospawner.spawner.SudoSpawner'> for bob:
[I 2020-08-05 21:54:16.824 JupyterHub log:174] 302 POST /hub/login?next= -> /hub/spawn (bob@::ffff:10.200.50.2) 12.46ms
[I 2020-08-05 21:54:16.831 JupyterHub log:174] 302 GET /hub/spawn -> /hub/login?next=%2Fhub%2Fspawn (@::ffff:10.200.50.2) 0.93ms
[I 2020-08-05 21:54:16.841 JupyterHub log:174] 200 GET /hub/login?next=%2Fhub%2Fspawn (@::ffff:10.200.50.2) 1.19ms
With c.JupyterHub.tornado_settings disabled
[I 2020-08-05 21:22:38.338 JupyterHub app:2631] JupyterHub is now running at http://:8000
[D 2020-08-05 21:22:38.339 JupyterHub app:2233] It took 1.251 seconds for the Hub to start
[I 2020-08-05 21:22:42.514 JupyterHub log:174] 302 GET / -> /hub/ (@::ffff:10.200.50.2) 1.13ms
[I 2020-08-05 21:22:42.521 JupyterHub log:174] 302 GET /hub/ -> /hub/login (@::ffff:10.200.50.2) 0.84ms
[I 2020-08-05 21:22:42.556 JupyterHub log:174] 200 GET /hub/login (@::ffff:10.200.50.2) 29.82ms
[D 2020-08-05 21:22:53.356 JupyterHub base:522] Setting cookie jupyterhub-session-id: {'httponly': True}
[D 2020-08-05 21:22:53.356 JupyterHub base:526] Setting cookie for bob: jupyterhub-hub-login
[D 2020-08-05 21:22:53.356 JupyterHub base:522] Setting cookie jupyterhub-hub-login: {'httponly': True, 'path': '/hub/'}
[I 2020-08-05 21:22:53.357 JupyterHub base:707] User logged in: bob
[D 2020-08-05 21:22:53.357 JupyterHub user:242] Creating <class 'sudospawner.spawner.SudoSpawner'> for bob:
[I 2020-08-05 21:22:53.363 JupyterHub log:174] 302 POST /hub/login?next= -> /hub/spawn (bob@::ffff:10.200.50.2) 14.58ms
[D 2020-08-05 21:22:53.385 JupyterHub pages:194] Triggering spawn with default options for bob
[D 2020-08-05 21:22:53.386 JupyterHub base:825] Initiating spawn for bob
[D 2020-08-05 21:22:53.386 JupyterHub base:829] 0/100 concurrent spawns
[D 2020-08-05 21:22:53.386 JupyterHub base:834] 0 active servers
[D 2020-08-05 21:22:53.445 JupyterHub user:556] Calling Spawner.start for bob
System:
jupyterhub --version
1.1.0
Python 3.8.3