Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

authentification of Ipython notebook using c.NotebookApp.login_handler_class parameter in config file

I've setup a Ipython 3.2.1 Notebook server. However, I'm looking for a way to add our own authentication rule, which means I want to add my own authentication security authentication mechanism similar to LDAP, OAuth to notebook.

I don't want to use JupyterHub, since it's too complex for me to use. However, I know from this site two factor authentication with username and password for a Jupyter Notebook server that we can deal with " The login handler class to use.

c.NotebookApp.login_handler_class = 'notebook.auth.login.LoginHandler'

in notebook configure file, but I don't know how to do it, do I need to write another loginHandler class to overwrite it? if so, which directory should I put this class file in?

like image 435
Sherry Xue Avatar asked Oct 31 '22 07:10

Sherry Xue


1 Answers

Yes, you can modify the behavior of the LoginHandler by extending it. Something like the code below where I am overwriting the method _render.

    class MyLoginHandler(LoginHandler):
        def _render(self, message=None):
            # ... this is my custom code

Then you have to modify the Jupyter file to something like:

c.NotebookApp.login_handler_class = 'myModule.MyLoginHandler'
like image 124
user3619911 Avatar answered Nov 11 '22 17:11

user3619911