Repository navigation
feat(git): configure GIT_PROVIDERS and clone GIT_REPOSITORIES at init - #444
Merged
Merged
Conversation
Onyxia now gives the services a list of Git forges (git.providers in the context), with a commit identity and credentials per forge. Support it, as JSON in GIT_PROVIDERS: - Commit identity per forge (includeIf hasconfig:remote.*.url). - Tokens in git-credential-store, scoped to the forge. - OAuth with git-credential-oauth, added to the base image. The refresh token obtained by Onyxia seeds git-credential-cache, which keeps the rotated ones. - The clone no longer puts a token in the URL for these forges, it would be saved in .git/config and outdated once refreshed. Bounded helpers and the device flow set up after the clone: git-credential-oauth waits with no limit on an interactive flow, the startup must not hang. Without GIT_PROVIDERS nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs onyxia-init.sh with one forge per kind of credentials and compares the generated files with their expected content, which also documents the result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GIT_REPOSITORIES holds git.repositories of the chart values, as JSON: the repositories picked in the Onyxia launcher, each with its branch. They're all cloned, a failed clone doesn't stop the startup. No token goes in the URL: the credentials come from GIT_PROVIDERS, the token of GIT_PERSONAL_ACCESS_TOKEN belongs to one forge and would be sent to all. Without GIT_REPOSITORIES, or with an empty array, GIT_REPOSITORY and GIT_BRANCH are used as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ddecrulle
added a commit
to InseeFrLab/helm-charts-dev
that referenced
this pull request
Nov 18, 2026
…t section trimmed Default image is now inseefrlab/onyxia-vscode-python:py3.13.15-git-providers, which ships the onyxia-init.sh of InseeFrLab/images-datascience#444 (GIT_PROVIDERS, GIT_REPOSITORIES). The previous tags stay in the list. The schema no longer exposes the legacy git.enabled/name/email/cache/token fields to the launcher. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ddecrulle
marked this pull request as ready for review
November 20, 2026 14:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Onyxia's Git integration (InseeFrLab/onyxia#1097) moves from one forge and one token to a list of forges (
git.providersin thexOnyxiacontext), each with its commit identity and its credentials: a token or OAuth. This teachesonyxia-init.shto configure them, from a newGIT_PROVIDERSvariable holding that list as JSON.It also clones every repository of a new
GIT_REPOSITORIESvariable: the repositories picked in the Onyxia launcher (git.repositoriesof the chart values), each with its branch.Without
GIT_PROVIDERSandGIT_REPOSITORIESnothing changes: existing charts and Onyxia versions keep the current behavior.What it does, per entry
includeIf "hasconfig:remote.*.url:<url>/**": commits use the identity of the forge of the repository,GIT_USER_NAME/GIT_USER_MAILremain the defaultcredentials.type: "token"git-credential-store, scoped to the forge (credential.<origin>.helper)credentials.type: "oauth"git-credential-oauthbehindgit-credential-cache. Added tobase, pinned and verified like the other toolsFor these forges the clone no longer puts a token in the URL: it ended up in plain text in
.git/config, in the project directory, and would be outdated after a refresh. The former path remains for repositories on a forge that isn't listed.Resulting configuration
With one forge per kind of credentials: OAuth with device flow (GitLab), OAuth without it (Forgejo), device flow only (GitHub) and a token (Bitbucket). This is the expected content of the new test in
base/tests.yaml, which compares it with whatonyxia-init.shgenerates.GIT_PROVIDERSused here[ {"id": "gitlab", "url": "https://gitlab.example.fr", "user": {"name": "Jane Doe", "email": "jane.doe@example.fr"}, "credentials": {"type": "oauth", "clientId": "CLIENT_ID_GITLAB", "scopes": ["read_repository", "write_repository"], "authorizationUrl": "https://gitlab.example.fr/oauth/authorize", "tokenUrl": "https://gitlab.example.fr/oauth/token", "deviceAuthorizationUrl": "https://gitlab.example.fr/oauth/authorize_device", "refreshToken": "REFRESH_TOKEN_GITLAB"}}, {"id": "github", "url": "https://github.com", "user": {"name": "jdoe", "email": "jdoe@users.noreply.github.com"}, "credentials": {"type": "oauth", "clientId": "CLIENT_ID_GITHUB", "scopes": ["repo"], "authorizationUrl": "https://github.com/login/oauth/authorize", "tokenUrl": "https://github.com/login/oauth/access_token", "deviceAuthorizationUrl": "https://github.com/login/device/code"}}, {"id": "forgejo", "url": "https://forge.example.org", "user": {"name": "Jane D.", "email": "jane@example.org"}, "credentials": {"type": "oauth", "clientId": "CLIENT_ID_FORGEJO", "scopes": ["write:repository"], "authorizationUrl": "https://forge.example.org/login/oauth/authorize", "tokenUrl": "https://forge.example.org/login/oauth/access_token", "refreshToken": "REFRESH_TOKEN_FORGEJO"}}, {"id": "bitbucket", "url": "https://bitbucket.org", "user": {"name": "Jane Doe", "email": "jane.doe@example.fr"}, "credentials": {"type": "token", "username": "x-bitbucket-api-token-auth", "token": "TOKEN_BITBUCKET"}} ]GIT_USER_NAME,GIT_USER_MAILandGIT_CREDENTIALS_CACHE_DURATION=0are also set.~/.gitconfig~/.gitconfig-onyxia-forgejo~/.git-credentials(mode 600)How to read it:
helper =(empty) isn't a mistake: it drops the helpers declared so far for this forge, so that the globalcache --timeout=0can't evict the refresh token.git-credential-oauthwhen the token is missing or expired.Repositories (
GIT_REPOSITORIES)[{"providerId": "gitlab", "url": "https://gitlab.example.fr/jane/project.git", "branch": "dev"}, {"providerId": "github", "url": "https://github.com/jane/other", "branch": ""}]ROOT_PROJECT_DIRECTORY, on its branch (an empty one clones the default branch).providerIdis ignored: git picks the credentials from the URL.GIT_PROVIDERS: the token ofGIT_PERSONAL_ACCESS_TOKENbelongs to one forge and would be sent to all of them.GIT_REPOSITORY/GIT_BRANCHare used as before. The charts set them to the first repository, for what still reads them (asCodeServerRoot, the RStudio project).Choices worth a review
git-credential-storecan't keep it, so it goes in the cache daemon, with an expired password: git discards the password and hands the refresh token togit-credential-oauth. This goes straight to the helper sincegit credential approveignores expired credentials.timeoutaroundgit-credential-oauth. When the refresh fails it falls back on an interactive flow and waits with no limit (<-queries, no deadline), which would hang the startup or agit pull: 30 s without device flow (a browser flow can't succeed from a service), 300 s with it.sudo -u, otherwise a root daemon would hold the user's credentials.unset GIT_PROVIDERSbefore starting the service: its processes don't need these secrets.credential.helper(GIT_CREDENTIALS_CACHE_DURATION) is reset per forge, its short timeout would evict the refresh token.Known limits
expirationTimeof a scoped token isn't used: past this date git gets a 401 and the user has to relaunch the service.PATH_TO_CA_BUNDLE,git-credential-oauth(Go) only trusts the system store: a CA that isn't in it would make the token endpoint calls fail. Not handled here.Before merging
Draft because the contract isn't settled on the other side:
GIT_PROVIDERSandGIT_REPOSITORIESthrough its schema overrides,ide/git.json(git.providers,git.repositories) andide/extraenv.json.extraEnvVarsvalues go throughtpl, so the chart serializes them withtoJson.Test plan
base/tests.yamlnow checks the generated configuration (above), the secrets staying out of the files and of the service's environment, and the identity per forge. Images aren't built on PRs, so this runs in the main workflow. I ran the full file locally withcontainer-structure-test(14/14) oninseefrlab/onyxia-base:latestwith this PR's scripts added, and checked that altering the script makes the new test fail.For what needs a forge, I also ran the real
onyxia-init.shininseefrlab/onyxia-base:latest(git 2.56, amd64 under emulation) with the new install script, against fake forges (git http-backendbehind Basic auth, OAuth token endpoint with rotation). The harness isn't part of this PR..git/configor.gitconfig,~/.git-credentialsin 600, files and daemon owned by the userGIT_CREDENTIALS_CACHE_DURATION=0doesn't evict the refresh tokenGIT_PROVIDERS, and repository on an unlisted forge: as beforeGIT_PROVIDERS, provider without credentialsshellcheck --severity=warningGIT_REPOSITORIES: the clone block run against local bare repositories (several repositories and branches, a missing one, an empty array, invalid JSON, nothing set). The new test inbase/tests.yamlhasn't run in a container yethadolint: to be covered by CI (it couldn't be installed locally)baseimage: the local run added the changes on top of the published image🤖 Generated with Claude Code