Missing support for project-level auth.json
- Dominant language
- PHP
- Stars
- 3.3k
- Forks
- 530
- Avg merge
- 6h 53m
- Merged PRs (30d)
- 13
Description
**Describe the bug**
The documentation states that Satis supports project-level `auth.json` files:
https://github.com/composer/satis/blob/24995745c2c6c8ca9cf70def61004b64314dec6c/docs/using.md#L215-L217
However, the current source code only supports global `auth.json` and doesn't use the project-level `auth.json` at all:
https://github.com/composer/satis/blob/24995745c2c6c8ca9cf70def61004b64314dec6c/src/Console/Command/BuildCommand.php#L283-L287
**To Reproduce**
1. Create a new project and require satis as a dependency in `composer.json`:
{
"name": "example/satis-example",
"type": "project",
"require": {
"composer/satis": "^1.0"
}
}
2. Add `satis.json` with a non-existent GitHub project repository (doesn't need to exist for this test):
{
"name": "satis/example",
"homepage": "http://satis.example.com",
"repositories": [
{ "type": "vcs", "url": "https://github.com/mycompany/privaterepo" }
],
"archive": {
"directory": "dist"
},
"require-all": true
}
3. Add `auth.json` to the current project directory by running `composer config github-oauth.github.com token123` (doesn't have to be a valid token).
4. Run the build `vendor/bin/satis build -vvv -n satis.json public` to produce the build and notice how it doesn't use the configured token:
```
Checked CA file /opt/homebrew/etc/ca-certificates/cert.pem: valid
Executing command (/path/to/project/satis-example): git branch -a --no-color --no-abbrev -v
Executing command (/path/to/project/satis-example): git describe --exact-match --tags
Executing command (CWD): git --version
Executing command (/path/to/project/satis-example): git log --pretty="%H" -n1 HEAD --no-show-signature
Executing command (/path/to/project/satis-example): hg branch
Executing command (/path/to/project/satis-example): fossil branch list
Executing command (/path/to/project/satis-example): fossil tag list
Executing command (/path/to/project/satis-example): svn info --xml
Failed to initialize global composer: Composer could not find the config file: /Users/kaspars/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Reading /path/to/project/satis-example/vendor/composer/installed.json
Scanning packages
Downloading https://api.github.com/repos/mycompany/privaterepo
Executing command (CWD): git config github.accesstoken
Executing command (CWD): git clone --mirror -- 'git@github.com:mycompany/privaterepo.git' '/Users/kaspars/.composer/cache/vcs/git-github.com-mycompany-privaterepo.git/'
Executing command (CWD): git config github.accesstoken
Executing command (CWD): git --version
Failed to clone the git@github.com:mycompany/privaterepo.git repository, try running in interactive mode so that you can enter your GitHub credentials
In Git.php line 404:
[RuntimeException]
Failed to execute git clone --mirror -- 'git@github.com:mycompany/privaterepo.git' '/Users/kaspars/.composer/cache/vcs/git-github.com-mycompany-p
rivaterepo.git/'
Cloning into bare repository '/Users/kaspars/.composer/cache/vcs/git-github.com-mycompany-privaterepo.git'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
```
**Outcome**
See above ☝️.
The `$config->get('home') . '/auth.json'` path points to the global Composer home directory so the local project-level `auth.json` isn't checked.
**Expected behavior**
Satis uses the `auth.json` data from the project root directory.
**Additional context**
None.
Contributor guide
Assessment
This issue has not been assessed yet.