Page MenuHomePhabricator

Simplify how GitHub oauth token is passed to composer
Closed, ResolvedPublic

Description

For most composer packages, the code is downloaded as an archive originating from github.com. They do enforce API rate limiting for unauthenticated users. With T106452, T248387 @bd808 went to generate a token:

I created https://github.com/composer-ratelimits-suck specifically for this purpose. I would be happy to share the account password with RelEng and/or SRE. There is nothing special about the account however, so it may be equally easy in the future to just spin up another GitHub account when needed.

This was done by e0982e0c4573e6dd32346d5e6499a881277f98d9 which changes the image entry point to set the composer config when the container starts:

if [ -n "${COMPOSER_GITHUB_OAUTHTOKEN}" ]; then
  /srv/composer/vendor/bin/composer config -g github-oauth.github.com "${COMPOSER_GITHUB_OAUTHTOKEN}"
fi

The token is stored in the Jenkins credential store and injected to jobs.

I am not sure the entry point is always called and the Quibble images do not set the composer config.


Instead of having to invoke composer config, we could rely on the COMPOSER_AUTH environment variable. It is described at https://getcomposer.org/doc/03-cli.md#composer-auth :

The COMPOSER_AUTH var allows you to set up authentication as an environment variable. The contents of the variable should be a JSON formatted object containing http-basic, github-oauth, bitbucket-oauth, ... objects as needed, and following the spec from the config.

And authentication as a whole is documented at https://getcomposer.org/doc/articles/authentication-for-private-packages.md

We can set a credential that exposes COMPOSER_AUTH={"github-oauth":{"github.com":"<TOKEN>"}} and this way we no more need to ensure the entry point is called or to rely on composer config.

Event Timeline

Change #1170347 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] jjb: remove GitHub token from castor-save-workspace-cache

https://gerrit.wikimedia.org/r/1170347

Mentioned in SAL (#wikimedia-releng) [2025-07-17T13:49:10Z] <hashar> jenkins: added composer-auth credentials which is a json blob intended to be passed as COMPOSER_AUTH environment variable # T399846

Change #1170348 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] jjb: beta: remove COMPOSER_GITHUB_OAUTHTOKEN

https://gerrit.wikimedia.org/r/1170348

Change #1170350 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] jjb: train-deploy-notes: rm COMPOSER_GITHUB_OAUTHTOKEN

https://gerrit.wikimedia.org/r/1170350

Change #1170347 abandoned by Hashar:

[integration/config@master] jjb: remove GitHub token from castor-save-workspace-cache

https://gerrit.wikimedia.org/r/1170347

Change #1170348 abandoned by Hashar:

[integration/config@master] jjb: beta: remove COMPOSER_GITHUB_OAUTHTOKEN

https://gerrit.wikimedia.org/r/1170348

Change #1170350 abandoned by Hashar:

[integration/config@master] jjb: train-deploy-notes: rm COMPOSER_GITHUB_OAUTHTOKEN

https://gerrit.wikimedia.org/r/1170350

Change #1170375 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] jjb: remove GitHub API token from all jobs

https://gerrit.wikimedia.org/r/1170375

Change #1170527 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] dockerfiles: composer: remove GitHub oauthtoken management

https://gerrit.wikimedia.org/r/1170527

Change #1170556 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] jjb: update jobs to use COMPOSER_AUTH

https://gerrit.wikimedia.org/r/1170556

Change #1170527 merged by jenkins-bot:

[integration/config@master] dockerfiles: composer: remove GitHub oauthtoken management

https://gerrit.wikimedia.org/r/1170527

Change #1170556 merged by jenkins-bot:

[integration/config@master] jjb: update jobs to no more use COMPOSER_GITHUB_OAUTHTOKEN

https://gerrit.wikimedia.org/r/1170556

Change #1170375 merged by jenkins-bot:

[integration/config@master] jjb: remove GitHub API token from all jobs

https://gerrit.wikimedia.org/r/1170375

Change #1170528 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] dockerfiles: rm composer wrapper and COMPOSER_DISABLE_XDEBUG_WARN=1

https://gerrit.wikimedia.org/r/1170528

Change #1170528 merged by jenkins-bot:

[integration/config@master] dockerfiles: rm composer wrapper and COMPOSER_DISABLE_XDEBUG_WARN=1

https://gerrit.wikimedia.org/r/1170528

Change #1170566 had a related patch set uploaded (by Hashar; author: Hashar):

[integration/config@master] jjb: update jobs to drop composer wrapper and COMPOSER_DISABLE_XDEBUG_WARN=1

https://gerrit.wikimedia.org/r/1170566

Change #1170566 merged by jenkins-bot:

[integration/config@master] jjb: update jobs to drop composer wrapper and COMPOSER_DISABLE_XDEBUG_WARN=1

https://gerrit.wikimedia.org/r/1170566

hashar claimed this task.

The CI Jenkins now sets COMPOSER_AUTH with a json payloads that has the GitHub OAuth token 🎉