A JupyterHub authenticator for Cloudflare Zero Trust that enables secure authentication using Cloudflare Access JWT tokens.
CF Authenticator is a custom authenticator for JupyterHub that integrates with Cloudflare Access to provide secure authentication. It validates JWT tokens issued by Cloudflare Access and uses the email address from the token as the username for JupyterHub sessions.
- Seamless integration with Cloudflare Access
- JWT token validation using Cloudflare's public signing keys
- Automatic user creation based on Cloudflare Access identity
- Configurable via environment variables
- Detailed logging for troubleshooting
pip install cf_authenticator
-
Set up your Cloudflare Access application and note down your Team Domain and Application Audience (AUD) tag.
-
Configure the following environment variables:
export POLICY_AUD="your-application-audience-tag" export TEAM_DOMAIN="https://your-team-domain.cloudflareaccess.com"
-
Configure JupyterHub to use the CF Authenticator by adding the following to your
jupyterhub_config.py
:c.JupyterHub.authenticator_class = 'cf_authenticator.CFAuthenticator'
- When a user accesses JupyterHub through Cloudflare Access, Cloudflare injects a JWT token in the request headers.
- The authenticator validates this token using Cloudflare's public signing keys.
- Upon successful validation, it extracts the user's email from the token.
- The email is used as the username for the JupyterHub session.
To set up the development environment:
-
Clone the repository:
git clone https://github.com/gcperformance/cf_authenticator.git cd cf_authenticator
-
Install development dependencies:
pip install -e .
- Python 3.6+
- PyJWT
- JupyterHub
Apache License 2.0
Kyle Fletcher ([email protected])