jupyterhub / gh-scoped-creds

Provide fine-grained push access to GitHub from a JupyterHub
BSD 3-Clause "New" or "Revised" License
25 stars 7 forks source link

Add Jupyter support #8

Closed fperez closed 2 years ago

fperez commented 2 years ago

Once installed, then inside a Notebook or Console using the IPython kernel, one can type

%run -m github_app_user_auth.jupyter

resulting in:

image

This doesn't modify the existing usage at the terminal, though it does add support for also calling the CLI entry point as python -m github_app_user_auth if desired.

This builds on the discussion from #7.

fperez commented 2 years ago

With this, it then becomes possible to make a convenient magic alias:

%alias_magic ghauth run -p "-m github_app_user_auth.jupyter"

and simply run

%ghauth

which is, for me, about as convenient as it's going to get, til we build a full UI :)

image

fperez commented 2 years ago

And for completeness, that magic alias can be permanently registered by putting in /home/jovyan/.ipython/profile_default/ipython_config.py this:

# Configuration file for ipython.

c = get_config()

c.InteractiveShellApp.exec_lines = ['%alias_magic ghauth run -p "-m github_app_user_auth.jupyter"']

and voilà! I now only need to type %ghauth whenever I log into our hubs, paste the code, and done :)

Thanks so much for getting this going! I need to switch gears and can't work on a Lab UI component now, but this will smooth out the experience for the students a lot.

fperez commented 2 years ago

cc @consideRatio - if Yuvi merges this, we may want to update the JMTE hub as well and mention this to the others :)

fperez commented 2 years ago

Thanks for the review @consideRatio! This is obviously a very simple iteration - if we like where this is going, I'm happy to later refactor the code a bit to make it more robust, and better separate the CLI functionality from the jupyter one, instead of using if statements. But I figured I'd do the minimal possible now to see if we like this pattern...

yuvipanda commented 2 years ago

Thanks for the PR, @fperez! Sorry it took a while to review :) I'm going to make some additional modifications - primarily to see if I can just implement the magic directly, and then make a release.

yuvipanda commented 2 years ago

@fperez @consideRatio I've added support for the IPython line magic directly in the code in https://github.com/yuvipanda/github-app-user-auth/pull/10. I've also simplified it a little and added a note to the docs.

fperez commented 2 years ago

Wonderful, thanks so much @yuvipanda!!

fperez commented 2 years ago

BTW, curious why you removed the opening of the other page on Enter? With the current version, it requires reaching over from the keboard, to the mouse (to click on the link), then again to the kbd... I'd been using the other workflow daily since February and found it very smooth, curious why you decided to change it?

yuvipanda commented 2 years ago

@fperez so Firefox always blocked the new window opening for me as an unwanted popup, so it was just confusing - I would press enter and nothing would happen. Plus a textbox that acted as an 'enter' felt a little weird on the web.

yuvipanda commented 2 years ago

I'll see if I can cook up some other js to prevent need for mouse use.

fperez commented 2 years ago

Ah, yes - you have to allow popups for that domain for it to work, correct... After that it worked well for me, but happy to explore other solutions :)

fperez commented 2 years ago

BTW - I think it's doable with a GUI popup too that has a keyboard-usable button, and would be probably more elegant. I just didn't have the time to find how to make that work, given my awful web skills.