Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

Extends Composer authentication support beyond GitHub to include GitLab, Bitbucket, and HTTP basic auth.

Changes

  • GitLab OAuth: GITLAB_OAUTH_TOKENgitlab-oauth.gitlab.com
  • GitLab Token: GITLAB_TOKENgitlab-token.gitlab.com
  • Bitbucket OAuth: BITBUCKET_CONSUMER_KEY + BITBUCKET_CONSUMER_SECRETbitbucket-oauth.bitbucket.org
  • HTTP Basic: HTTP_BASIC_AUTH (JSON) → http-basic.*

All providers respect existing COMPOSER_AUTH values without overriding. Invalid inputs (malformed JSON, partial credentials) are silently ignored.

Example usage:

# GitLab token
GITLAB_TOKEN=glpat_xyz wp package install vendor/package

# HTTP basic auth for custom repo
HTTP_BASIC_AUTH='{"repo.example.com":{"username":"user","password":"pass"}}' wp package install vendor/package
Original prompt

This section details on the original issue you should resolve

<issue_title>Handle more git providers in set_composer_auth_env_var()</issue_title>
<issue_description>As of #47, we support GitHub. There are a few other providers we could support too:

  • bitbucket-oauth
  • gitlab-oauth
  • gitlab-token
  • http-basic</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 25, 2026 17:35
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for additional git providers in set_composer_auth_env_var Handle additional git providers in set_composer_auth_env_var() Jan 25, 2026
Copilot AI requested a review from swissspidy January 25, 2026 17:38
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a 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_TOKEN and GITLAB_TOKEN environment variables
  • Added support for BITBUCKET_CONSUMER_KEY and BITBUCKET_CONSUMER_SECRET environment variables
  • Added support for HTTP_BASIC_AUTH environment variable (JSON format)
  • All new providers respect existing COMPOSER_AUTH values 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 ) ) {
Copy link

Copilot AI Jan 25, 2026

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 ] : []).

Copilot uses AI. Check for mistakes.

// GitLab personal access token.
$gitlab_token = getenv( 'GITLAB_TOKEN' );
if ( ! isset( $composer_auth['gitlab-token'] ) && is_string( $gitlab_token ) ) {
Copy link

Copilot AI Jan 25, 2026

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.

Copilot uses AI. Check for mistakes.
swissspidy and others added 3 commits January 25, 2026 12:59
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle more git providers in set_composer_auth_env_var()

2 participants