millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

Need advice on manual login flow #572

Closed kittipatv closed 4 years ago

kittipatv commented 5 years ago

Hi, I need some advice on implementing manual login flow. I want to use this package at my company. We have 2-factor authentication on the login page. I wonder where should I start to implement a custom login flow?

Thanks!

dickmao commented 5 years ago

I read this and saw nothing to suggest that notebooks servers enforce 2FA. We do not presently support jupyterhub logins.

dickmao commented 5 years ago

If you could implement a basic oauth handshake with jupyterhub in elisp outside of EIN, I could integrate it into EIN. It would not be a good use of your time to learn EIN's messy login logic.

kittipatv commented 5 years ago

Is there a way to connection using JSON connection info (similar to https://github.com/gregsexton/ob-ipython#working-with-a-remote-session)? I could use %connection_info to get it from an existing session.

dickmao commented 5 years ago

EIN does not support remote consoles in the ob-ipython style. Frankly, that style is very error-prone and inconvenient. It is only mildly improved upon here in that you don't need to copy the kernel.json locally (but still need to know the exact filename, which is unwieldy).

EIN only supports the command ein:login to a remote notebook server. There is also ein:connect-to-notebook and ob-ein if you do not wish to use the ipynb format. For whatever reason, your second message no longer seemed interested in 2FA.

kittipatv commented 5 years ago

2-factor is only necessary to obtain the access token. I think the most straightforward way for me to use this would be to supply the access token manually. It's a bit inconvenient but I usually keep the server running for days so I don't have to re-auth often.

dickmao commented 5 years ago

Is this what you mean by "2-factor"? If not, then I presume your institution has implemented a custom 2FA screen in front of a notebook server. That is not something EIN should code for unless that 2FA screen is jupyterhub (I would be interested in a screenshot if you're unsure).

token

kittipatv commented 5 years ago

I think I misunderstood %connect_info. It seems to require connecting to some specific notebook. That wouldn't work here.

The installation I work with user cookie for authentication. The login page looks like this.

notebook-login

I don't think EIN should be supporting this officially. Thus, I'm looking for a way to hook up the login page with EIN login logic. If EIN supports cookie, then it should not be too hard to make it read and send another field (in my local fork).

dickmao commented 5 years ago

EIN does accept an extra tag-value pair via C-u M-x ein:login. This, as you say, allows users to access notebook servers requiring very basic cookie auth.

I can't advise on the 2FA. I barely understand the cookie auth.