plasmabio / tljh-repo2docker

Plugin for The Littlest JupyterHub to build multiple user environments with repo2docker
BSD 3-Clause "New" or "Revised" License
60 stars 15 forks source link

Add support for private repositories #27

Closed jtpio closed 3 years ago

jtpio commented 4 years ago

For now tljh-repo2docker can build environments from repositories that are publicly accessible.

However it would be useful if it could also build environments from private repositories.

BinderHub supports this use case with the git_credentials option.

The value is then passed as a GIT_CREDENTIAL_ENV environment variable to the builder (the jupyter/repo2docker:master Docker image): https://github.com/jupyterhub/binderhub/blob/3cb82fafa55d25e8fb6c6559423ffdef57919aa3/binderhub/build.py#L236

For tljh-repo2docker, we would need to pass these credentials using the GIT_CREDENTIAL_ENV environment variable to the command here:

https://github.com/plasmabio/tljh-repo2docker/blob/05ce3d589822797e2834301239e76f0950bd87a8/tljh_repo2docker/docker.py#L82-L96

Something like the following:

cmd = [
    "GIT_CREDENTIAL_ENV=username=foo\npassword=bar",
    "jupyter-repo2docker",
    "--ref",
    ref,
    "--user-name",
    "jovyan",
    "--user-id",
    "1100",
    "--no-run",
    "--image-name",
    image_name,
    "--appendix",
    "\n".join(labels),
    repo,
]

The credentials could be specified in the form:

add-new

Or as a configurable for the tljh_repo2docker plugin.

jtpio commented 4 years ago

Documentation to access private repositories for BinderHub:

https://binderhub.readthedocs.io/en/latest/zero-to-binderhub/setup-binderhub.html?accessing-private-repositories#accessing-private-repositories

The token can be generated from the GitLab UI:

image

pierrepo commented 4 years ago

And I guess similar things could be done with the GitHub UI:

image

SylvainCorlay commented 4 years ago

Optional extra git credentials could be in a <detail> section of the form.

There could be an option to fill the password with the hub authentication token for the case where we use the gitlab's SSO.