drupal/security_layer 问题修复 & 功能扩展

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

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

drupal/security_layer

Composer 安装命令:

composer require drupal/security_layer

包简介

Installs and configures Password Policy and sets 90 day expiration default.

README 文档

README

Version: 0.1 Machine Name: security_layer
Type: Recipe Author: Carla Mola Compatible with: Drupal 11.x

Introduction

Security Layer is a ready-to-use configuration recipe that strengthens your Drupal site’s security by automatically installing and configuring essential security modules. It enforces password policies, two-factor authentication (2FA), form protection, brute-force prevention, session control, data encryption, and HTTP header hardening.

Designed for developers and administrators who want to apply best practices in security quickly and reliably.

Features

Strong Password Policies

  • Minimum 12 characters.
  • Must contain at least 4 types of characters.
  • Prevents reuse of the last 5 passwords.
  • Cannot include the username.
  • Passwords expire every 90 days.

Session Timeout and Control

  • Automatically logs out users after 30 minutes of inactivity.
  • Maximum session length configurable (default: 2 hours).
  • Session tracking and logout logs enabled.
  • Applies only to authenticated users.

Brute-force Protection

  • Maximum 5 failed login attempts.
  • Activity logged after 10 failed attempts within 1 hour.
  • Temporary blocking enabled.

CAPTCHA on Critical Forms

  • Math-based challenge.
  • Enabled for login, registration, and password reset.
  • Case-insensitive validation.

Two-Factor Authentication (2FA)

  • Based on TOTP (e.g., Google Authenticator).
  • Enabled by default for all authenticated users.
  • 10 recovery codes generated per user.
  • 6 failed attempts allowed per 5 minutes (flood control).
  • Email notifications on 2FA enable/disable actions.

Data Encryption

  • AES-256 encryption via the real_aes module.
  • Encryption key stored securely using the key module.
  • Key is Base64-encoded and must be manually generated (see below).
  • Integrates with encrypt, key, and real_aes.

Secure HTTP Headers

  • Removes insecure or unnecessary headers (X-Powered-By, Server).
  • Sets strict security policies:
  • X-Frame-Options: SAMEORIGIN
  • X-XSS-Protection: 1; mode=block
  • Strict-Transport-Security
  • Basic Content-Security-Policy (CSP)

Performance Tuning

  • Enables CSS and JS aggregation.
  • Browser and proxy caching set to 1 hour.

Requirements

Required Contributed Modules

This recipe depends on the following Drupal modules:

  • password_policy
  • captcha
  • flood_control
  • tfa
  • encrypt
  • key
  • real_aes
  • secure_headers

All of them are automatically installed via Composer when applying the recipe.

Installation

Step 1: Add the repository (if not on drupal.org)

  1. Requiring this Recipe

    composer require drupal/security_layer:1.0.0`
    
  2. Applying this Recipe

    drush cr
    drush recipe security_layer
    

Post-installation Configuration

  1. Generate your own encryption key Before enabling encryption features, you must generate a secure 256-bit key:

    openssl rand -base64 32
    

    This produces a Base64-encoded 256-bit key.

  2. Then, open the file: config/install/key.key.encryption_key.yml Find the key_value field and replace its content with your generated key.

    key_value: YOUR_BASE64_ENCODED_KEY_HERE
    

    Do not use the default key in production environments.

drupal/security_layer 适用场景与选型建议

drupal/security_layer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「recipe」 「drupal recipes」 「drupal recipe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 drupal/security_layer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2025-05-28