##// END OF EJS Templates
add example for downgrading a notebook to v3 in whatsnew
Min RK -
Show More
@@ -1,314 +1,320 b''
1 ============
1 ============
2 3.x Series
2 3.x Series
3 ============
3 ============
4
4
5
5
6 Release 3.0
6 Release 3.0
7 ===========
7 ===========
8
8
9 Coming February, 2015
9 Coming February, 2015
10
10
11 This is a really big release. Over 150 contributors, and almost 6000 commits in a bit under a year.
11 This is a really big release. Over 150 contributors, and almost 6000 commits in a bit under a year.
12 Support for languages other than Python is greatly improved,
12 Support for languages other than Python is greatly improved,
13 notebook UI has been significantly redesigned,
13 notebook UI has been significantly redesigned,
14 and a lot of improvement has happened in the experimental interactive widgets.
14 and a lot of improvement has happened in the experimental interactive widgets.
15 The message protocol and document format have both been updated,
15 The message protocol and document format have both been updated,
16 while maintaining better compatibility with previous versions than prior updates.
16 while maintaining better compatibility with previous versions than prior updates.
17 The notebook webapp now enables editing of any text file, and even
17 The notebook webapp now enables editing of any text file, and even
18 a web-based terminal (on Unix platforms).
18 a web-based terminal (on Unix platforms).
19
19
20 3.x will be the last monolithic release of IPython,
20 3.x will be the last monolithic release of IPython,
21 as the next release cycle will see the growing project split into its Python-specific and language-agnostic components.
21 as the next release cycle will see the growing project split into its Python-specific and language-agnostic components.
22 Language-agnostic projects (notebook, qtconsole, etc.) will move under the umbrella of the new Project Jupyter name,
22 Language-agnostic projects (notebook, qtconsole, etc.) will move under the umbrella of the new Project Jupyter name,
23 while Python-specific projects (interactive Python shell, Python kernel, IPython.parallel)
23 while Python-specific projects (interactive Python shell, Python kernel, IPython.parallel)
24 will remain under IPython, and be split into a few smaller packages.
24 will remain under IPython, and be split into a few smaller packages.
25 To reflect this, IPython is in a bit of a transition state.
25 To reflect this, IPython is in a bit of a transition state.
26 The logo on the notebook is now the Jupyter logo.
26 The logo on the notebook is now the Jupyter logo.
27 When installing kernels system-wide, they go in a `jupyter` directory.
27 When installing kernels system-wide, they go in a `jupyter` directory.
28 We are going to do our best to ease this transition for users and developers.
28 We are going to do our best to ease this transition for users and developers.
29
29
30 Big changes are ahead.
30 Big changes are ahead.
31
31
32
32
33 Using different kernels
33 Using different kernels
34 -----------------------
34 -----------------------
35
35
36 .. image:: ../_images/kernel_selector_screenshot.png
36 .. image:: ../_images/kernel_selector_screenshot.png
37 :alt: Screenshot of 'new' dropdown showing different kernels
37 :alt: Screenshot of 'new' dropdown showing different kernels
38 :align: center
38 :align: center
39
39
40 You can now choose a kernel for a notebook within the user interface, rather
40 You can now choose a kernel for a notebook within the user interface, rather
41 than starting up a separate notebook server for each kernel you want to use. The
41 than starting up a separate notebook server for each kernel you want to use. The
42 syntax highlighting adapts to match the language you're working in.
42 syntax highlighting adapts to match the language you're working in.
43
43
44 Information about the kernel is stored in the notebook file, so when you open a
44 Information about the kernel is stored in the notebook file, so when you open a
45 notebook, it will automatically start the correct kernel.
45 notebook, it will automatically start the correct kernel.
46
46
47 It is also easier to use the Qt console and the terminal console with other
47 It is also easier to use the Qt console and the terminal console with other
48 kernels, using the --kernel flag::
48 kernels, using the --kernel flag::
49
49
50 ipython qtconsole --kernel bash
50 ipython qtconsole --kernel bash
51 ipython console --kernel bash
51 ipython console --kernel bash
52
52
53 # To list available kernels
53 # To list available kernels
54 ipython kernelspec list
54 ipython kernelspec list
55
55
56 Kernel authors should see :ref:`kernelspecs` for how to register their kernels
56 Kernel authors should see :ref:`kernelspecs` for how to register their kernels
57 with IPython so that these mechanisms work.
57 with IPython so that these mechanisms work.
58
58
59 Typing unicode identifiers
59 Typing unicode identifiers
60 --------------------------
60 --------------------------
61
61
62 .. image:: /_images/unicode_completion.png
62 .. image:: /_images/unicode_completion.png
63
63
64 Complex expressions can be much cleaner when written with a wider choice of
64 Complex expressions can be much cleaner when written with a wider choice of
65 characters. Python 3 allows unicode identifiers, and IPython 3 makes it easier
65 characters. Python 3 allows unicode identifiers, and IPython 3 makes it easier
66 to type those, using a feature from Julia. Type a backslash followed by a LaTeX
66 to type those, using a feature from Julia. Type a backslash followed by a LaTeX
67 style short name, such as ``\alpha``. Press tab, and it will turn into Ξ±.
67 style short name, such as ``\alpha``. Press tab, and it will turn into Ξ±.
68
68
69 Widget migration guide
69 Widget migration guide
70 ----------------------
70 ----------------------
71 The widget framework has a lot of backwards incompatible changes. For information about migrating widget notebooks and custom widgets to 3.0 refer to the :doc:`widget migration guide<version3_widget_migration>`.
71 The widget framework has a lot of backwards incompatible changes. For information about migrating widget notebooks and custom widgets to 3.0 refer to the :doc:`widget migration guide<version3_widget_migration>`.
72
72
73 Other new features
73 Other new features
74 ------------------
74 ------------------
75
75
76 * :class:`~.TextWidget` and :class:`~.TextareaWidget` objects now include a
76 * :class:`~.TextWidget` and :class:`~.TextareaWidget` objects now include a
77 ``placeholder`` attribute, for displaying placeholder text before the
77 ``placeholder`` attribute, for displaying placeholder text before the
78 user has typed anything.
78 user has typed anything.
79
79
80 * The :magic:`load` magic can now find the source for objects in the user namespace.
80 * The :magic:`load` magic can now find the source for objects in the user namespace.
81 To enable searching the namespace, use the ``-n`` option.
81 To enable searching the namespace, use the ``-n`` option.
82
82
83 .. sourcecode:: ipython
83 .. sourcecode:: ipython
84
84
85 In [1]: %load -n my_module.some_function
85 In [1]: %load -n my_module.some_function
86
86
87 * :class:`~.DirectView` objects have a new :meth:`~.DirectView.use_cloudpickle`
87 * :class:`~.DirectView` objects have a new :meth:`~.DirectView.use_cloudpickle`
88 method, which works like ``view.use_dill()``, but causes the ``cloudpickle``
88 method, which works like ``view.use_dill()``, but causes the ``cloudpickle``
89 module from PiCloud's `cloud`__ library to be used rather than dill or the
89 module from PiCloud's `cloud`__ library to be used rather than dill or the
90 builtin pickle module.
90 builtin pickle module.
91
91
92 __ https://pypi.python.org/pypi/cloud
92 __ https://pypi.python.org/pypi/cloud
93
93
94 * Added a .ipynb exporter to nbconvert. It can be used by passing `--to notebook`
94 * Added a .ipynb exporter to nbconvert. It can be used by passing `--to notebook`
95 as a commandline argument to nbconvert.
95 as a commandline argument to nbconvert.
96
96
97 * New nbconvert preprocessor called :class:`~.ClearOutputPreprocessor`. This
97 * New nbconvert preprocessor called :class:`~.ClearOutputPreprocessor`. This
98 clears the output from IPython notebooks.
98 clears the output from IPython notebooks.
99
99
100 * New preprocessor for nbconvert that executes all the code cells in a notebook.
100 * New preprocessor for nbconvert that executes all the code cells in a notebook.
101 To run a notebook and save its output in a new notebook::
101 To run a notebook and save its output in a new notebook::
102
102
103 ipython nbconvert InputNotebook --ExecutePreprocessor.enabled=True --to notebook --output Executed
103 ipython nbconvert InputNotebook --ExecutePreprocessor.enabled=True --to notebook --output Executed
104
104
105 * Consecutive stream (stdout/stderr) output is merged into a single output
105 * Consecutive stream (stdout/stderr) output is merged into a single output
106 in the notebook document.
106 in the notebook document.
107 Previously, all output messages were preserved as separate output fields in the JSON.
107 Previously, all output messages were preserved as separate output fields in the JSON.
108 Now, the same merge is applied to the stored output as the displayed output,
108 Now, the same merge is applied to the stored output as the displayed output,
109 improving document load time for notebooks with many small outputs.
109 improving document load time for notebooks with many small outputs.
110
110
111 * ``NotebookApp.webapp_settings`` is deprecated and replaced with
111 * ``NotebookApp.webapp_settings`` is deprecated and replaced with
112 the more informatively named ``NotebookApp.tornado_settings``.
112 the more informatively named ``NotebookApp.tornado_settings``.
113
113
114 * Using :magic:`timeit` prints warnings if there is atleast a 4x difference in timings
114 * Using :magic:`timeit` prints warnings if there is atleast a 4x difference in timings
115 between the slowest and fastest runs, since this might meant that the multiple
115 between the slowest and fastest runs, since this might meant that the multiple
116 runs are not independent of one another.
116 runs are not independent of one another.
117
117
118 * It's now possible to provide mechanisms to integrate IPython with other event
118 * It's now possible to provide mechanisms to integrate IPython with other event
119 loops, in addition to the ones we already support. This lets you run GUI code
119 loops, in addition to the ones we already support. This lets you run GUI code
120 in IPython with an interactive prompt, and to embed the IPython
120 in IPython with an interactive prompt, and to embed the IPython
121 kernel in GUI applications. See :doc:`/config/eventloops` for details. As part
121 kernel in GUI applications. See :doc:`/config/eventloops` for details. As part
122 of this, the direct ``enable_*`` and ``disable_*`` functions for various GUIs
122 of this, the direct ``enable_*`` and ``disable_*`` functions for various GUIs
123 in :mod:`IPython.lib.inputhook` have been deprecated in favour of
123 in :mod:`IPython.lib.inputhook` have been deprecated in favour of
124 :meth:`~.InputHookManager.enable_gui` and :meth:`~.InputHookManager.disable_gui`.
124 :meth:`~.InputHookManager.enable_gui` and :meth:`~.InputHookManager.disable_gui`.
125
125
126 * A ``ScrollManager`` was added to the notebook. The ``ScrollManager`` controls how the notebook document is scrolled using keyboard. Users can inherit from the ``ScrollManager`` or ``TargetScrollManager`` to customize how their notebook scrolls. The default ``ScrollManager`` is the ``SlideScrollManager``, which tries to scroll to the nearest slide or sub-slide cell.
126 * A ``ScrollManager`` was added to the notebook. The ``ScrollManager`` controls how the notebook document is scrolled using keyboard. Users can inherit from the ``ScrollManager`` or ``TargetScrollManager`` to customize how their notebook scrolls. The default ``ScrollManager`` is the ``SlideScrollManager``, which tries to scroll to the nearest slide or sub-slide cell.
127
127
128 * The function :func:`~IPython.html.widgets.interaction.interact_manual` has been
128 * The function :func:`~IPython.html.widgets.interaction.interact_manual` has been
129 added which behaves similarly to :func:`~IPython.html.widgets.interaction.interact`,
129 added which behaves similarly to :func:`~IPython.html.widgets.interaction.interact`,
130 but adds a button to explicitly run the interacted-with function, rather than
130 but adds a button to explicitly run the interacted-with function, rather than
131 doing it automatically for every change of the parameter widgets. This should
131 doing it automatically for every change of the parameter widgets. This should
132 be useful for long-running functions.
132 be useful for long-running functions.
133
133
134 * The ``%cython`` magic is now part of the Cython module. Use `%load_ext Cython` with a version of Cython >= 0.21 to have access to the magic now.
134 * The ``%cython`` magic is now part of the Cython module. Use `%load_ext Cython` with a version of Cython >= 0.21 to have access to the magic now.
135
135
136 * The Notebook application now offers integrated terminals on Unix platforms,
136 * The Notebook application now offers integrated terminals on Unix platforms,
137 intended for when it is used on a remote server. To enable these, install
137 intended for when it is used on a remote server. To enable these, install
138 the ``terminado`` Python package.
138 the ``terminado`` Python package.
139
139
140 * The Notebook application can now edit any plain text files, via a full-page CodeMirror instance.
140 * The Notebook application can now edit any plain text files, via a full-page CodeMirror instance.
141
141
142 * Setting the default highlighting language for nbconvert with the config option
142 * Setting the default highlighting language for nbconvert with the config option
143 ``NbConvertBase.default_language`` is deprecated. Nbconvert now respects
143 ``NbConvertBase.default_language`` is deprecated. Nbconvert now respects
144 metadata stored in the :ref:`kernel spec <kernelspecs>`.
144 metadata stored in the :ref:`kernel spec <kernelspecs>`.
145
145
146 * IPython can now be configured systemwide, with files in :file:`/etc/ipython`
146 * IPython can now be configured systemwide, with files in :file:`/etc/ipython`
147 or :file:`/usr/local/etc/ipython` on Unix systems,
147 or :file:`/usr/local/etc/ipython` on Unix systems,
148 or :file:`{%PROGRAMDATA%}\\ipython` on Windows.
148 or :file:`{%PROGRAMDATA%}\\ipython` on Windows.
149
149
150 * Added support for configurable user-supplied `Jinja
150 * Added support for configurable user-supplied `Jinja
151 <http://jinja.pocoo.org/>`_ HTML templates for the notebook. Paths to
151 <http://jinja.pocoo.org/>`_ HTML templates for the notebook. Paths to
152 directories containing template files can be specified via
152 directories containing template files can be specified via
153 ``NotebookApp.extra_template_paths``. User-supplied template directories
153 ``NotebookApp.extra_template_paths``. User-supplied template directories
154 searched first by the notebook, making it possible to replace existing
154 searched first by the notebook, making it possible to replace existing
155 templates with your own files.
155 templates with your own files.
156
156
157 For example, to replace the notebook's built-in ``error.html`` with your own,
157 For example, to replace the notebook's built-in ``error.html`` with your own,
158 create a directory like ``/home/my_templates`` and put your override template
158 create a directory like ``/home/my_templates`` and put your override template
159 at ``/home/my_templates/error.html``. To start the notebook with your custom
159 at ``/home/my_templates/error.html``. To start the notebook with your custom
160 error page enabled, you would run::
160 error page enabled, you would run::
161
161
162 ipython notebook '--extra_template_paths=["/home/my_templates/"]'
162 ipython notebook '--extra_template_paths=["/home/my_templates/"]'
163
163
164 It's also possible to override a template while also `inheriting
164 It's also possible to override a template while also `inheriting
165 <http://jinja.pocoo.org/docs/dev/templates/#template-inheritance>`_ from that
165 <http://jinja.pocoo.org/docs/dev/templates/#template-inheritance>`_ from that
166 template, by prepending ``templates/`` to the ``{% extends %}`` target of
166 template, by prepending ``templates/`` to the ``{% extends %}`` target of
167 your child template. This is useful when you only want to override a
167 your child template. This is useful when you only want to override a
168 specific block of a template. For example, to add additional CSS to the
168 specific block of a template. For example, to add additional CSS to the
169 built-in ``error.html``, you might create an override that looks like::
169 built-in ``error.html``, you might create an override that looks like::
170
170
171 {% extends "templates/error.html" %}
171 {% extends "templates/error.html" %}
172
172
173 {% block stylesheet %}
173 {% block stylesheet %}
174 {{super()}}
174 {{super()}}
175 <style type="text/css">
175 <style type="text/css">
176 /* My Awesome CSS */
176 /* My Awesome CSS */
177 </style>
177 </style>
178 {% endblock %}
178 {% endblock %}
179
179
180 * Added a widget persistence API. This allows you to persist your notebooks interactive widgets.
180 * Added a widget persistence API. This allows you to persist your notebooks interactive widgets.
181 Two levels of control are provided:
181 Two levels of control are provided:
182 1. Higher level- ``WidgetManager.set_state_callbacks`` allows you to register callbacks for loading and saving widget state. The callbacks you register are automatically called when necessary.
182 1. Higher level- ``WidgetManager.set_state_callbacks`` allows you to register callbacks for loading and saving widget state. The callbacks you register are automatically called when necessary.
183 2. Lower level- the ``WidgetManager`` Javascript class now has ``get_state`` and ``set_state`` methods that allow you to get and set the state of the widget runtime.
183 2. Lower level- the ``WidgetManager`` Javascript class now has ``get_state`` and ``set_state`` methods that allow you to get and set the state of the widget runtime.
184
184
185 Example code for persisting your widget state to session data::
185 Example code for persisting your widget state to session data::
186
186
187 %%javascript
187 %%javascript
188 require(['widgets/js/manager'], function(manager) {
188 require(['widgets/js/manager'], function(manager) {
189 manager.WidgetManager.set_state_callbacks(function() { // Load
189 manager.WidgetManager.set_state_callbacks(function() { // Load
190 return JSON.parse(sessionStorage.widgets_state || '{}');
190 return JSON.parse(sessionStorage.widgets_state || '{}');
191 }, function(state) { // Save
191 }, function(state) { // Save
192 sessionStorage.widgets_state = JSON.stringify(state);
192 sessionStorage.widgets_state = JSON.stringify(state);
193 });
193 });
194 });
194 });
195
195
196 * Enhanced support for :magic:`env` magic. As before, :magic:`env` with no
196 * Enhanced support for :magic:`env` magic. As before, :magic:`env` with no
197 arguments displays all environment variables and values. Additionally,
197 arguments displays all environment variables and values. Additionally,
198 :magic:`env` can be used to get or set individual environment variables. To
198 :magic:`env` can be used to get or set individual environment variables. To
199 display an individual value, use the `%env var` syntax. To set a value, use
199 display an individual value, use the `%env var` syntax. To set a value, use
200 `env var val` or `env var=val`. Python value expansion using `$` works as usual.
200 `env var val` or `env var=val`. Python value expansion using `$` works as usual.
201
201
202
202
203 Backwards incompatible changes
203 Backwards incompatible changes
204 ------------------------------
204 ------------------------------
205
205
206 * The :ref:`message protocol <messaging>` has been updated from version 4 to version 5.
206 * The :ref:`message protocol <messaging>` has been updated from version 4 to version 5.
207 Adapters are included, so IPython frontends can still talk to kernels that
207 Adapters are included, so IPython frontends can still talk to kernels that
208 implement protocol version 4.
208 implement protocol version 4.
209
209
210 * The :ref:`notebook format <nbformat>` has been updated from version 3 to version 4.
210 * The :ref:`notebook format <nbformat>` has been updated from version 3 to version 4.
211 Read-only support for v4 notebooks has been backported to IPython 2.4.
211 Read-only support for v4 notebooks has been backported to IPython 2.4.
212 Notable changes:
212 Notable changes:
213
213
214 * heading cells are removed in favor or markdown headings
214 * heading cells are removed in favor or markdown headings
215 * notebook outputs and output messages are more consistent with each other
215 * notebook outputs and output messages are more consistent with each other
216 * use :func:`IPython.nbformat.read` and :func:`~IPython.nbformat.write`
216 * use :func:`IPython.nbformat.read` and :func:`~IPython.nbformat.write`
217 to read and write notebook files
217 to read and write notebook files
218 instead of the deprecated :mod:`IPython.nbformat.current` APIs.
218 instead of the deprecated :mod:`IPython.nbformat.current` APIs.
219
219
220 You can downgrade a notebook to v3 via ``nbconvert``::
221
222 ipython nbconvert --to notebook --nbformat 3 [notebook]
223
224 which will create :file:`notebook.v3.ipynb`, a copy of the notebook in v3 format.
225
220 * :func:`IPython.core.oinspect.getsource` call specification has changed:
226 * :func:`IPython.core.oinspect.getsource` call specification has changed:
221
227
222 * `oname` keyword argument has been added for property source formatting
228 * `oname` keyword argument has been added for property source formatting
223 * `is_binary` keyword argument has been dropped, passing ``True`` had
229 * `is_binary` keyword argument has been dropped, passing ``True`` had
224 previously short-circuited the function to return ``None`` unconditionally
230 previously short-circuited the function to return ``None`` unconditionally
225
231
226 * Removed the octavemagic extension: it is now available as ``oct2py.ipython``.
232 * Removed the octavemagic extension: it is now available as ``oct2py.ipython``.
227
233
228 * Creating PDFs with LaTeX no longer uses a post processor.
234 * Creating PDFs with LaTeX no longer uses a post processor.
229 Use `nbconvert --to pdf` instead of `nbconvert --to latex --post pdf`.
235 Use `nbconvert --to pdf` instead of `nbconvert --to latex --post pdf`.
230
236
231 * Used https://github.com/jdfreder/bootstrap2to3 to migrate the Notebook to Bootstrap 3.
237 * Used https://github.com/jdfreder/bootstrap2to3 to migrate the Notebook to Bootstrap 3.
232
238
233 Additional changes:
239 Additional changes:
234
240
235 - Set `.tab-content .row` `0px;` left and right margin (bootstrap default is `-15px;`)
241 - Set `.tab-content .row` `0px;` left and right margin (bootstrap default is `-15px;`)
236 - Removed `height: @btn_mini_height;` from `.list_header>div, .list_item>div` in `tree.less`
242 - Removed `height: @btn_mini_height;` from `.list_header>div, .list_item>div` in `tree.less`
237 - Set `#header` div `margin-bottom: 0px;`
243 - Set `#header` div `margin-bottom: 0px;`
238 - Set `#menus` to `float: left;`
244 - Set `#menus` to `float: left;`
239 - Set `#maintoolbar .navbar-text` to `float: none;`
245 - Set `#maintoolbar .navbar-text` to `float: none;`
240 - Added no-padding convenience class.
246 - Added no-padding convenience class.
241 - Set border of #maintoolbar to 0px
247 - Set border of #maintoolbar to 0px
242
248
243 * Accessing the `container` DOM object when displaying javascript has been
249 * Accessing the `container` DOM object when displaying javascript has been
244 deprecated in IPython 2.0 in favor of accessing `element`. Starting with
250 deprecated in IPython 2.0 in favor of accessing `element`. Starting with
245 IPython 3.0 trying to access `container` will raise an error in browser
251 IPython 3.0 trying to access `container` will raise an error in browser
246 javascript console.
252 javascript console.
247
253
248 * ``IPython.utils.py3compat.open`` was removed: :func:`io.open` provides all
254 * ``IPython.utils.py3compat.open`` was removed: :func:`io.open` provides all
249 the same functionality.
255 the same functionality.
250
256
251 * The NotebookManager and ``/api/notebooks`` service has been replaced by
257 * The NotebookManager and ``/api/notebooks`` service has been replaced by
252 a more generic ContentsManager and ``/api/contents`` service,
258 a more generic ContentsManager and ``/api/contents`` service,
253 which supports all kinds of files.
259 which supports all kinds of files.
254 * The Dashboard now lists all files, not just notebooks and directories.
260 * The Dashboard now lists all files, not just notebooks and directories.
255 * The ``--script`` hook for saving notebooks to Python scripts is removed,
261 * The ``--script`` hook for saving notebooks to Python scripts is removed,
256 use :samp:`ipython nbconvert --to python {notebook}` instead.
262 use :samp:`ipython nbconvert --to python {notebook}` instead.
257
263
258 * The ``rmagic`` extension is deprecated, as it is now part of rpy2. See
264 * The ``rmagic`` extension is deprecated, as it is now part of rpy2. See
259 :mod:`rpy2.ipython.rmagic`.
265 :mod:`rpy2.ipython.rmagic`.
260
266
261 * :meth:`~.KernelManager.start_kernel` and :meth:`~.KernelManager.format_kernel_cmd`
267 * :meth:`~.KernelManager.start_kernel` and :meth:`~.KernelManager.format_kernel_cmd`
262 no longer accept a ``executable`` parameter. Use the kernelspec machinery instead.
268 no longer accept a ``executable`` parameter. Use the kernelspec machinery instead.
263
269
264 * The widget classes have been renamed from `*Widget` to `*`. The old names are
270 * The widget classes have been renamed from `*Widget` to `*`. The old names are
265 still functional, but are deprecated. i.e. `IntSliderWidget` has been renamed
271 still functional, but are deprecated. i.e. `IntSliderWidget` has been renamed
266 to `IntSlider`.
272 to `IntSlider`.
267 * The ContainerWidget was renamed to Box and no longer defaults as a flexible
273 * The ContainerWidget was renamed to Box and no longer defaults as a flexible
268 box in the web browser. A new FlexBox widget was added, which allows you to
274 box in the web browser. A new FlexBox widget was added, which allows you to
269 use the flexible box model.
275 use the flexible box model.
270
276
271 * The notebook now uses a single websocket at `/kernels/<kernel-id>/channels` instead of separate
277 * The notebook now uses a single websocket at `/kernels/<kernel-id>/channels` instead of separate
272 `/kernels/<kernel-id>/{shell|iopub|stdin}` channels. Messages on each channel are identified by a
278 `/kernels/<kernel-id>/{shell|iopub|stdin}` channels. Messages on each channel are identified by a
273 `channel` key in the message dict, for both send and recv.
279 `channel` key in the message dict, for both send and recv.
274
280
275
281
276 Content Security Policy
282 Content Security Policy
277 ```````````````````````
283 ```````````````````````
278
284
279 The Content Security Policy is a web standard for adding a layer of security to
285 The Content Security Policy is a web standard for adding a layer of security to
280 detect and mitigate certain classes of attacks, including Cross Site Scripting
286 detect and mitigate certain classes of attacks, including Cross Site Scripting
281 (XSS) and data injection attacks. This was introduced into the notebook to
287 (XSS) and data injection attacks. This was introduced into the notebook to
282 ensure that the IPython Notebook and its APIs (by default) can only be embedded
288 ensure that the IPython Notebook and its APIs (by default) can only be embedded
283 in an iframe on the same origin.
289 in an iframe on the same origin.
284
290
285 Override ``headers['Content-Security-Policy']`` within your notebook
291 Override ``headers['Content-Security-Policy']`` within your notebook
286 configuration to extend for alternate domains and security settings.::
292 configuration to extend for alternate domains and security settings.::
287
293
288 c.NotebookApp.tornado_settings = {
294 c.NotebookApp.tornado_settings = {
289 'headers': {
295 'headers': {
290 'Content-Security-Policy': "frame-ancestors 'self'"
296 'Content-Security-Policy': "frame-ancestors 'self'"
291 }
297 }
292 }
298 }
293
299
294 Example policies::
300 Example policies::
295
301
296 Content-Security-Policy: default-src 'self' https://*.jupyter.org
302 Content-Security-Policy: default-src 'self' https://*.jupyter.org
297
303
298 Matches embeddings on any subdomain of jupyter.org, so long as they are served
304 Matches embeddings on any subdomain of jupyter.org, so long as they are served
299 over SSL.
305 over SSL.
300
306
301 There is a `report-uri <https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives#report-uri>`_ endpoint available for logging CSP violations, located at
307 There is a `report-uri <https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives#report-uri>`_ endpoint available for logging CSP violations, located at
302 ``/api/security/csp-report``. To use it, set ``report-uri`` as part of the CSP::
308 ``/api/security/csp-report``. To use it, set ``report-uri`` as part of the CSP::
303
309
304 c.NotebookApp.tornado_settings = {
310 c.NotebookApp.tornado_settings = {
305 'headers': {
311 'headers': {
306 'Content-Security-Policy': "frame-ancestors 'self'; report-uri /api/security/csp-report"
312 'Content-Security-Policy': "frame-ancestors 'self'; report-uri /api/security/csp-report"
307 }
313 }
308 }
314 }
309
315
310 It simply provides the CSP report as a warning in IPython's logs. The default
316 It simply provides the CSP report as a warning in IPython's logs. The default
311 CSP sets this report-uri relative to the ``base_url`` (not shown above).
317 CSP sets this report-uri relative to the ``base_url`` (not shown above).
312
318
313 For a more thorough and accurate guide on Content Security Policies, check out
319 For a more thorough and accurate guide on Content Security Policies, check out
314 `MDN's Using Content Security Policy <https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy>`_ for more examples.
320 `MDN's Using Content Security Policy <https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy>`_ for more examples.
General Comments 0
You need to be logged in to leave comments. Login now