marcosimbuerger / symfony-monitoring-satellite-bundle
Symfony的监控卫星
1.0.0
2020-12-29 20:07 UTC
Requires
- php: >=7.4
- symfony/http-foundation: ^4.4|^5.0
- symfony/http-kernel: ^4.4|^5.0
This package is auto-updated.
Last update: 2024-09-29 06:08:34 UTC
README
监控卫星为监控站提供关于您的Symfony应用程序的数据。
安装
安装包
$ composer require marcosimbuerger/symfony-monitoring-satellite-bundle
启用包
检查您的config/bundles.php
。监控卫星包应该已经自动添加。如果没有,请手动添加。
// config/bundles.php return [ // ... MarcoSimbuerger\MonitoringSatelliteBundle\MarcoSimbuergerMonitoringSatelliteBundle::class => ['all' => true], ];
配置
导入路由
导入监控卫星包的路由到您的Symfony应用程序中。
# config/routes.yaml monitoringsatellite_get: resource: "@MarcoSimbuergerMonitoringSatelliteBundle/Resources/config/routes.yaml"
配置您的应用程序的security.yml
为了保护监控卫星包,您必须在安全文件中这样做。security.yml文件包含您应用程序的基本安全配置。
在编码器中,定义Symfony\Component\Security\Core\User\User
类。此内部类用于表示内存中的用户。
在提供者部分下,创建一个monitoring_satellite_auth_provider
提供者,并配置一个带密码的内存用户。使用bin/console security:encode-password
生成密码散列。
在防火墙部分下定义认证。添加监控卫星包路由的模式并定义之前创建的提供者用于基本认证。
在访问控制部分指定尝试访问应用程序特定部分的用户所需的凭证。再次在那里定义路由。
以下是使用监控卫星包在应用程序中所需配置的示例
# config/packages/security.yaml security: encoders: Symfony\Component\Security\Core\User\User: algorithm: auto providers: monitoring_satellite_auth_provider: memory: users: # Define a user with password. # Use 'bin/console security:encode-password' to generate the password hash. foo: password: '$argon2id$v=19$m=65536,t=4,p=1$ofPY6RT+0rCE74M0AlPpzQ$BeiGUhv27D4/6FBmNKC0r4dhImZqj55EfOwYqjxaVbE' roles: ROLE_USER firewalls: # Secure the MonitoringSatelliteBundle's route with basic auth. monitoring_satellite_controller: pattern: ^/monitoring-satellite/v1/get http_basic: provider: monitoring_satellite_auth_provider access_control: - { path: ^/monitoring-satellite/v1/get, roles: ROLE_USER }
测试
调用/monitoring-satellite/v1/get
。
它应该由基本认证保护,并在认证成功后返回应用程序数据。
将卫星添加到站
将此监控卫星添加到监控站。请参阅监控站文档。
许可证
此包在MIT许可证下发布。有关更多信息,请参阅包含的LICENSE文件。