-
Notifications
You must be signed in to change notification settings - Fork 19
Handle additional git providers in set_composer_auth_env_var() #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR extends Composer authentication support beyond GitHub to include GitLab (OAuth and personal access tokens), Bitbucket OAuth, and HTTP Basic Auth, allowing WP-CLI to authenticate with multiple Git providers when installing packages.
Changes:
- Added support for
GITLAB_OAUTH_TOKENandGITLAB_TOKENenvironment variables - Added support for
BITBUCKET_CONSUMER_KEYandBITBUCKET_CONSUMER_SECRETenvironment variables - Added support for
HTTP_BASIC_AUTHenvironment variable (JSON format) - All new providers respect existing
COMPOSER_AUTHvalues without overriding - Added comprehensive unit tests and feature tests for all new providers
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/Package_Command.php | Extends set_composer_auth_env_var() method to handle GitLab, Bitbucket, and HTTP Basic Auth environment variables, following the same pattern as existing GitHub support |
| tests/PackageAuthTest.php | Adds comprehensive unit tests covering all new auth providers, edge cases (partial credentials, invalid JSON), and verification that existing auth is preserved |
| features/package-auth.feature | Adds Behat scenarios to test real-world usage of all new authentication providers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // GitHub OAuth token. | ||
| $github_token = getenv( 'GITHUB_TOKEN' ); | ||
| if ( ! isset( $composer_auth['github-oauth'] ) && is_string( $github_token ) ) { |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition is_string( $github_token ) will accept empty strings, which could result in empty authentication tokens being added to COMPOSER_AUTH. Consider adding an additional check to ensure the token is not empty, such as is_string( $github_token ) && '' !== $github_token, which would be more consistent with the truthy check pattern used elsewhere in this file (e.g., line 939: $github_token ? [ 'Authorization' => 'token ' . $github_token ] : []).
|
|
||
| // GitLab personal access token. | ||
| $gitlab_token = getenv( 'GITLAB_TOKEN' ); | ||
| if ( ! isset( $composer_auth['gitlab-token'] ) && is_string( $gitlab_token ) ) { |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition is_string( $gitlab_token ) will accept empty strings, which could result in empty authentication tokens being added to COMPOSER_AUTH. Consider adding an additional check to ensure the token is not empty, such as is_string( $gitlab_token ) && '' !== $gitlab_token.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Extends Composer authentication support beyond GitHub to include GitLab, Bitbucket, and HTTP basic auth.
Changes
GITLAB_OAUTH_TOKEN→gitlab-oauth.gitlab.comGITLAB_TOKEN→gitlab-token.gitlab.comBITBUCKET_CONSUMER_KEY+BITBUCKET_CONSUMER_SECRET→bitbucket-oauth.bitbucket.orgHTTP_BASIC_AUTH(JSON) →http-basic.*All providers respect existing
COMPOSER_AUTHvalues without overriding. Invalid inputs (malformed JSON, partial credentials) are silently ignored.Example usage:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.