zhortein/dev-security-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

zhortein/dev-security-bundle

最新稳定版本:1.0.2

Composer 安装命令:

composer require --dev zhortein/dev-security-bundle

包简介

Secure your Symfony dev environment without losing comfort.

README 文档

README

🔒 Secure your Symfony dev environment without losing comfort.

CI codecov PHP Version Symfony Version License: MIT

This bundle protects Symfony development environments from accidental exposure of sensitive data.
It restricts access to the Web Debug Toolbar, Profiler, and other debug routes to a whitelist of IPs or reverse hostnames.

🚀 Installation

composer require --dev zhortein/dev-security-bundle

Then register it (Symfony Flex usually handles this automatically):

// config/bundles.php
return [
    Zhortein\DevSecurityBundle\ZhorteinDevSecurityBundle::class => ['dev' => true, 'test' => true],
];

⚙️ Configuration

Create config/packages/zhortein_dev_security.yaml with configuration options:

zhortein_dev_security:
    enabled: true
    allowed_ips:
        - 127.0.0.1
        - ::1
        - 192.168.1.0/24
        - 10.8.0.0/16
    allowed_hosts:
        - "*.mydomain.fr"
        - "*.otherdomain.com"
    log_blocked_attempts: true

🧠 Features

✅ Restricts Symfony Web Debug Toolbar & Profiler to allowed IPs / CIDR / hostnames ✅ Logs blocked attempts for audit ✅ Optional #[RestrictedToDevWhitelist] attribute to secure sensitive routes (e.g. /dev/info) ✅ Zero dependency, works out of the box

🧰 Usage Example

use Zhortein\DevSecurityBundle\Attribute\RestrictedToDevWhitelist;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

#[Route('/dev/info')]
#[RestrictedToDevWhitelist]
public function devInfo(): Response
{
    return new Response('This route is visible only to authorized developer IPs.');
}

If accessed from an unauthorized IP, the bundle throws AccessDeniedHttpException (403).

🛠️ Roadmap

Version Feature
1.0.0 Base security (profiler restriction, route attribute)
1.1.0 Command-line helper to list current IPs and detect reverses
1.2.0 Middleware to disable exception stacktraces in preprod
2.0.0 Audit dashboard & metrics integration

🧑‍💻 Author

David Renard CEO at Isatis Concept

📝 License

MIT © David Renard

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-18