承接 hryvinskyi/composer-multi-auth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hryvinskyi/composer-multi-auth

Composer 安装命令:

composer require hryvinskyi/composer-multi-auth

包简介

Composer plugin for per-package HTTP basic auth on a single repository domain

README 文档

README

Composer plugin that enables per-package HTTP basic authentication on a single repository domain.

Problem

Composer resolves HTTP basic auth by domain — one credential pair per domain in auth.json. When a single repository hosts packages from different vendors requiring different API keys, there's no native way to use per-package credentials.

How It Works

The plugin reads auth-multi.json from your project root and:

  1. Overrides default auth with the first rule's credentials during repository metadata discovery (so the provider listing includes all packages you need).
  2. Intercepts each download via Composer's PRE_FILE_DOWNLOAD event and applies the correct credentials based on package name glob patterns.
  3. Restores default credentials for packages that don't match any specific rule.

First matching rule wins. Use * as a catch-all.

Requirements

  • PHP 8.1+
  • Composer 2.x

Installation

composer require hryvinskyi/composer-multi-auth

Add to allow-plugins in your composer.json if prompted:

{
    "config": {
        "allow-plugins": {
            "hryvinskyi/composer-multi-auth": true
        }
    }
}

Setup

On first activation the plugin automatically:

  • Creates auth-multi.json.sample in the project root
  • Adds auth-multi.json to .gitignore

Then create your config:

  1. Copy the sample and fill in your keys:
cp auth-multi.json.sample auth-multi.json
  1. Edit auth-multi.json:
{
    "http-basic": {
        "private.repo.example.com": {
            "rules": [
                {
                    "patterns": ["acme/*"],
                    "username": "acme-public-key",
                    "password": "acme-private-key"
                },
                {
                    "patterns": ["*"],
                    "username": "your-default-public-key",
                    "password": "your-default-private-key"
                }
            ]
        }
    }
}

Configuration

auth-multi.json

{
    "http-basic": {
        "<domain>": {
            "rules": [
                {
                    "patterns": ["<glob-pattern>", ...],
                    "username": "<public-key>",
                    "password": "<private-key>"
                }
            ]
        }
    }
}
Field Description
http-basic Top-level key (matches Composer's auth.json structure)
<domain> Repository domain
rules Ordered array of rules — first match wins
patterns Array of glob patterns matched via fnmatch() (e.g., vendor/*, vendor/package)
username HTTP basic auth username / public key
password HTTP basic auth password / private key

Rule ordering

Rules are evaluated top-to-bottom. The first rule whose patterns match the package name is used. Always place specific rules before the catch-all * rule.

Catch-all rule

The catch-all rule ("patterns": ["*"]) should be the last rule and should contain your default auth.json credentials. This ensures packages not matching any specific rule still authenticate correctly.

Important: The first rule's credentials are used for repository metadata discovery (loading the package listing). Place the rule for the packages you need to discover first.

Verification

Run Composer with verbose output to see the plugin in action:

composer install -vvv

Look for [multi-auth] prefixed messages:

Loading plugin Hryvinskyi\ComposerMultiAuth\Plugin
[multi-auth] Loaded rules for 1 domain(s).
[multi-auth] Applying credentials for package "acme/some-package" on "private.repo.example.com".
[multi-auth] Restoring default credentials for package "other/package" on "private.repo.example.com".

License

MIT

hryvinskyi/composer-multi-auth 适用场景与选型建议

hryvinskyi/composer-multi-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 hryvinskyi/composer-multi-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hryvinskyi/composer-multi-auth 我们能提供哪些服务?
定制开发 / 二次开发

基于 hryvinskyi/composer-multi-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-04