Jupyter Hub - AWS
  • Overview
  • Pre-requisites
  • Disclaimer
  • AWS: Instance Launching
    • Overview
    • Customizing an Instance
    • Assigning an Elastic IP Address
    • Connecting to Your Cloud
    • Ubuntu: Server Update and Add Users
  • Anaconda
    • Overview
    • Anaconda Installation
    • JupyterHub Installation and Configuration
  • R
    • R Installation
    • Update and Install IR Kernel
  • Stata
    • Overview
    • Stata Installation
    • Stata Kernel for Jupyter
  • (Optional) GitHub Extension and Packages
    • GitHub Extension
    • nbgrader
  • (Optional) Add a Custom Domain
    • Overview
    • Adding a Subdomain
  • (Optional) GitHub Authentication
    • Overview
    • Generate Cookie Secret
    • Secure Your Lab
    • Add GitHub Authentication
Powered by GitBook
On this page
  1. (Optional) GitHub Authentication

Add GitHub Authentication

PreviousSecure Your Lab

Last updated 1 year ago

Execute the following to set up a method for students to sign in using GitHub.

From your GitHub account, navigate to the Developer Settings. Choose OAth Apps and create a New OAth app. Enter the corresponding information. Enter https://YOUR-URL/hub/oauth_callbackas the Authorization callback URL, being careful to replace YOUR-URL with the link to your lab.

On your Ubuntu server, install GitHub OAuth:

conda install -c conda-forge oauthenticator

Open the JupyterHub configuration file

nano /etc/jupyterhub/jupyterhub_config.py

Copy and paste the following into the file, being careful to replace the URL, Client ID, and Client Secret with your own. The Client ID and Client Secret can be found on the page of the GitHub "app" created above.

from oauthenticator.github import LocalGitHubOAuthenticator
c.JupyterHub.authenticator_class = LocalGitHubOAuthenticator
c.LocalGitHubOAuthenticator.oauth_callback_url = 'YOUR-URL/hub/oauth_callback'
c.LocalGitHubOAuthenticator.client_id = 'YOUR CLIENT ID'
c.LocalGitHubOAuthenticator.client_secret = 'YOUR CLIENT SECRET'

# This line means that it will no longer be necessary to manually add new users.
c.LocalGitHubOAuthenticator.create_system_users = True
c.LocalGitHubOAuthenticator.allow_all = True

It should look like this:

Notice that you may also change the admin username to your GitHub username to allow administrative access.

Use CTRL+O then enter to overwrite the document and CTRL+X to exit.

Reboot the server:

systemctl restart jupyterhub.service