tourze / wechat-mini-program-plugin-bundle
微信小程序插件
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/wechat-mini-program-plugin-bundle
Requires
- psr/log: ^3|^2|^1
- symfony/config: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/event-dispatcher: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-foundation: ^7.3
- symfony/http-kernel: ^7.3
- symfony/property-access: ^7.3
- symfony/yaml: ^7.3
- tourze/bundle-dependency: 1.*
- tourze/json-rpc-core: 1.0.*
- tourze/symfony-dependency-service-loader: 1.0.*
- tourze/wechat-mini-program-bundle: 1.0.*
- yiisoft/json: ^1.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- tourze/phpunit-base: 1.*
- tourze/phpunit-symfony-kernel-test: 1.0.*
- tourze/phpunit-symfony-unit-test: 1.*
This package is auto-updated.
Last update: 2025-11-10 13:02:43 UTC
README
A Symfony bundle for WeChat Mini Program plugin request signature verification.
Installation
Install the package via Composer:
composer require tourze/wechat-mini-program-plugin-bundle
Quick Start
- Add the bundle to your
config/bundles.php:
<?php return [ // ... other bundles WechatMiniProgramPluginBundle\WechatMiniProgramPluginBundle::class => ['all' => true], ];
- The bundle will automatically register the
HostSignCheckSubscriberto verify WeChat Mini Program plugin requests.
Features
- Request Signature Verification: Automatically validates
X-WECHAT-HOSTSIGNheader - AppID Extraction: Extracts AppID from referrer URL
- Security: Ensures request authenticity using SHA1 signature verification
- Logging: Comprehensive logging for debugging and monitoring
Usage
The bundle automatically handles WeChat Mini Program plugin request verification through the HostSignCheckSubscriber. When a request contains the X-WECHAT-HOSTSIGN header, the subscriber will:
- Extract the signature data from the header
- Parse the AppID from the referrer URL
- Verify the signature using the configured plugin token
- Throw an exception if the signature is invalid
Example Request Headers
X-WECHAT-HOSTSIGN: {"noncestr":"RANDOM_STRING", "timestamp":"1234567890", "signature":"SHA1_SIGNATURE"}
Referrer: https://servicewechat.com/wx1234567890abcdef/1/page-frame.html
Configuration
The bundle requires the tourze/wechat-mini-program-bundle package to be properly configured with WeChat Mini Program accounts and plugin tokens.
License
This project is licensed under the MIT License - see the LICENSE file for details.