Skip to content

Commit

Permalink
Merge pull request jupyter-server#219 from fcollonval/patch-1
Browse files Browse the repository at this point in the history
Add `authenticated` decorator to handlers in doc
  • Loading branch information
Zsailer authored May 5, 2020
2 parents da33b05 + 48feaee commit 0005f58
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/source/developers/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,20 @@ The easiest way to add endpoints and handle incoming requests is to subclass the
.. code-block:: python
from jupyter_server.base.handlers import JupyterHandler
import tornado
class MyExtensionHandler(JupyterHandler):
@tornado.web.authenticated
def get(self):
...
@tornado.web.authenticated
def post(self):
...
.. note::
It is best practice to wrap each handler method with the ``authenticated`` decorator to ensure that each request is authenticated by the server.

Then add this handler to Jupyter Server's Web Application through the ``_load_jupyter_server_extension`` function.

Expand Down Expand Up @@ -178,13 +183,16 @@ Jupyter Server provides a convenient mixin class for adding these properties to
from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.extension.handler import ExtensionHandlerMixin
import tornado
class MyExtensionHandler(ExtensionHandlerMixin, JupyterHandler):
@tornado.web.authenticated
def get(self):
...
@tornado.web.authenticated
def post(self):
...
Expand Down Expand Up @@ -217,16 +225,19 @@ Pair the example above with ``ExtensionHandlers`` that also inherit the ``Extens
ExtensionHandlerMixin,
ExtensionHandlerJinjaMixin
)
import tornado
class MyExtensionHandler(
ExtensionHandlerMixin,
ExtensionHandlerJinjaMixin,
JupyterHandler
):
@tornado.web.authenticated
def get(self):
...
@tornado.web.authenticated
def post(self):
...
Expand Down

0 comments on commit 0005f58

Please sign in to comment.