Skip to main content

JupyterLab git extension with OAuth device flow for GitLab and GitHub

Project description

Publish to PyPI Publish to TestPyPI CI

jupyterlab-git-oauth

JupyterLab Git extension with OAuth 2.0 Device Authorization Grant for GitLab and GitHub. Designed for Kubeflow Notebooks and JupyterHub environments where users are identified by OIDC/SSO headers rather than local Unix accounts.

What it is

A single pip package that replaces jupyterlab-git with:

  • OAuth device flow — authenticate to GitLab and GitHub directly from JupyterLab's status bar; no password or personal access token required
  • OIDC author injection — automatically sets git user.name and user.email from the Kubeflow/OIDC user header on every commit
  • Git credential helpergit-credential-jupyterlab-oauth lets terminal git operations reuse the same OAuth token without re-prompting
  • Token refresh — background broker keeps access tokens fresh across long-running notebook sessions

Why it exists

In Kubeflow Notebooks, every pod runs as the same jovyan user, but the actual person is identified by an OIDC header injected by oauth2-proxy (e.g., kubeflow-userid). Stock jupyterlab-git:

  • doesn't know how to read OAuth tokens from a JupyterHub-managed store
  • uses the pod's Unix identity for git author, not the OIDC user
  • has no device flow UI

This package patches the two files that matter (jupyterlab_git/handlers.py, jupyterlab_git/git.py) and bundles a Jupyter Server extension providing the OAuth device flow API.

Fork basis

Forked from jupyterlab-git 0.52.0.
The upstream labextension TypeScript and the fork Python patches are combined into a single installable wheel — no separate installs, no version mismatches.

Features

Feature GitLab GitHub
Device Authorization Grant (RFC 8628)
Token refresh
OIDC author injection
Status bar widget
Git credential helper

Requirements

GitLab

Create an OAuth application (Admin Area → Applications or group/user settings) with:

  • Grant type: Device Authorization Code
  • Scopes: read_user, read_repository, write_repository

GitHub

Create an OAuth App (Settings → Developer settings → OAuth Apps) with device flow enabled (check "Enable Device Flow" in app settings).

Installation

pip install jupyterlab-git-oauth

This installs the labextension, the Jupyter Server extension, and the git-credential-jupyterlab-oauth helper into PATH. The server extension auto-enables itself; no jupyter server extension enable step is needed.

Configuration

Set environment variables before starting Jupyter:

Variable Default Description
GITLAB_CLIENT_ID (none — GitLab disabled) GitLab application client ID
GITLAB_URL https://gitlab.com GitLab instance URL (for self-hosted: https://gitlab.example.com)
GITHUB_CLIENT_ID (none — GitHub disabled) GitHub OAuth app client ID

A provider is only activated when its CLIENT_ID variable is set.

Usage

  1. Open JupyterLab — the status bar shows "GitLab: Not connected"
  2. Click the status bar item → a device code is displayed in a dialog
  3. Open the authorization URL, enter the code → the dialog confirms success
  4. The status bar turns green; git clone / pull / push work from the JupyterLab UI

Terminal git operations also work without re-prompting. The credential helper is auto-configured on Jupyter Server startup (git config --global credential.helper jupyterlab-oauth).

To disconnect: click the status bar item again and choose Disconnect.

Docker image

FROM your-jupyter-base-image
RUN pip install jupyterlab-git-oauth

ENV GITLAB_CLIENT_ID=your-application-client-id
ENV GITLAB_URL=https://gitlab.example.com
# Optional: ENV GITHUB_CLIENT_ID=your-github-app-client-id

Development setup

Requirements: Python 3.9+, Node.js 20+

git clone https://github.com/stachuzamora/jupyterlab-git-oauth.git
cd jupyterlab-git-oauth

# Install JS dependencies and build the labextension
yarn install
yarn run build:prod

# Install the Python package in editable mode
pip install -e .

# Start Jupyter with provider env vars
GITLAB_CLIENT_ID=abc123 GITLAB_URL=https://gitlab.example.com jupyter lab

To watch TypeScript changes during development:

# Terminal 1
yarn watch

# Terminal 2
jupyter lab

License

BSD-3-Clause — see LICENSE.
Upstream jupyterlab-git is also BSD-3-Clause.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_git_oauth-0.52.5.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterlab_git_oauth-0.52.5-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file jupyterlab_git_oauth-0.52.5.tar.gz.

File metadata

  • Download URL: jupyterlab_git_oauth-0.52.5.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jupyterlab_git_oauth-0.52.5.tar.gz
Algorithm Hash digest
SHA256 d13e8e2434cfb8e996616c52ee280228101fb17459df03ec46f335d8e74f97a9
MD5 89f14cfe2ba1ea563dc388dca16d128f
BLAKE2b-256 f2bdf9684cafdad33b68b88d5dff659fc82989440587ded7ba679fdbcef6a2ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyterlab_git_oauth-0.52.5.tar.gz:

Publisher: publish.yml on stachuzamora/jupyterlab-git-oauth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jupyterlab_git_oauth-0.52.5-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlab_git_oauth-0.52.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3145c123a5ea303f3cadbf6ee2f368b711c1f1693713230a7652054c6a71ace8
MD5 9171232064d55cc4b79a60efebe8672d
BLAKE2b-256 c6fed0cf218d842ae95eb005276b533c72d3c83832c2e94e0867a0232f4fef9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for jupyterlab_git_oauth-0.52.5-py3-none-any.whl:

Publisher: publish.yml on stachuzamora/jupyterlab-git-oauth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page