Azure AD Setup#
Install oauthenticator with required dependency
pip3 install "oauthenticator[azuread]"
Set the
AAD_TENANT_ID
environment variableexport AAD_TENANT_ID='{AAD-TENANT-ID}'
Add the code below to your
jupyterhub_config.py
fileimport os from oauthenticator.azuread import AzureAdOAuthenticator c.JupyterHub.authenticator_class = AzureAdOAuthenticator c.Application.log_level = 'DEBUG' c.AzureAdOAuthenticator.tenant_id = os.environ.get('AAD_TENANT_ID') c.AzureAdOAuthenticator.oauth_callback_url = 'http://{your-domain}/hub/oauth_callback' c.AzureAdOAuthenticator.client_id = '{AAD-APP-CLIENT-ID}' c.AzureAdOAuthenticator.client_secret = '{AAD-APP-CLIENT-SECRET}'
This sample code is provided for you in
examples > azuread > sample_jupyter_config.py
Make sure to replace the values in
'{}'
with your APP, TENANT, DOMAIN, etc. valuesYou might need to add at least the
openid
scope if your organization requires MFA (c.AzureAdOAuthenticator.scope = ['openid']
), in addition to whatever else you need.CLIENT_ID === Azure Application ID, found in:
Azure portal --> AD --> App Registrations --> App
TENANT_ID === Azure Directory ID, found in:
Azure portal --> AD --> Properties
Run via:
sudo jupyterhub -f ./path/to/jupyterhub_config.py
See
run.sh
for an example