spatie-security

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Spatie Security Guidelines

Spatie安全指南

Overview

概述

Apply Spatie's security best practices when building, configuring, or reviewing applications and infrastructure.
在构建、配置或审查应用程序与基础设施时,遵循Spatie的安全最佳实践。

When to Activate

适用场景

  • Activate this skill when configuring application security (authentication, authorization, forms).
  • Activate this skill when setting up or reviewing database configurations.
  • Activate this skill when configuring servers or reviewing infrastructure.
  • Activate this skill when reviewing code for security vulnerabilities.
  • 配置应用程序安全(身份验证、授权、表单)时启用此技能。
  • 设置或审查数据库配置时启用此技能。
  • 配置服务器或审查基础设施时启用此技能。
  • 审查代码以排查安全漏洞时启用此技能。

Scope

适用范围

  • In scope: Application security, database security, server configuration, credential management.
  • Out of scope: Code style, business logic, UI/UX design.
  • 纳入范围:应用程序安全、数据库安全、服务器配置、凭证管理。
  • 排除范围:代码风格、业务逻辑、UI/UX设计。

Application Security

应用程序安全

  • Transmit all HTTP traffic over SSL.
  • Use CSRF tokens in all forms.
  • Use appropriate HTTP methods for significant actions:
    DELETE
    ,
    POST
    ,
    PUT
    — never
    GET
    .
  • Add automated authorization tests to verify only authorized users can access restricted functionality.
  • 所有HTTP流量均通过SSL传输。
  • 在所有表单中使用CSRF令牌。
  • 对重要操作使用合适的HTTP方法:
    DELETE
    POST
    PUT
    —— 绝不要使用
    GET
  • 添加自动化授权测试,以验证只有授权用户才能访问受限功能。

Database Security

数据库安全

  • Hash all stored passwords.
  • Encrypt API keys stored in databases.
  • Use separate database users per database with appropriate read/write permissions.
  • Restrict database access to whitelisted hosts only (webserver and developer machines).
  • 对所有存储的密码进行哈希处理。
  • 加密数据库中存储的API密钥。
  • 为每个数据库使用独立的数据库用户,并配置合适的读写权限。
  • 仅允许白名单主机(Web服务器和开发人员机器)访问数据库。

Server Security

服务器安全

  • Keep NGINX, PHP, Ubuntu, and similar software up to date.
  • Use SSH with private key authentication; disable password authentication.
  • Install and enable
    unattended-upgrades
    for automatic security updates.
  • Configure firewalls to permit only necessary traffic (typically ports 22 and 443).
  • Manage all servers through Ansible for rapid patching and access revocation.
  • 保持NGINX、PHP、Ubuntu及同类软件为最新版本。
  • 使用带私钥认证的SSH;禁用密码认证。
  • 安装并启用
    unattended-upgrades
    以实现自动安全更新。
  • 配置防火墙仅允许必要的流量(通常为22和443端口)。
  • 通过Ansible管理所有服务器,以实现快速补丁部署和权限撤销。

Credential Management

凭证管理

  • Store all passwords in a password manager (e.g. 1Password).
  • Ensure each password is unique; no reuse.
  • Enable two-factor authentication when available.
  • Protect all private keys with passwords.
  • 将所有密码存储在密码管理器中(如1Password)。
  • 确保每个密码都是唯一的;禁止重复使用。
  • 尽可能启用双因素认证。
  • 为所有私钥设置密码保护。

General

通用规则

  • Use backups (e.g. BackBlaze) and test them periodically.
  • Enable FileVault (full-disk encryption) on all Macs.
  • Never use public services like Pastebin for sensitive code or data.
  • Install browser extensions only from official stores; minimize usage.

  • 使用备份服务(如BackBlaze)并定期测试备份。
  • 在所有Mac设备上启用FileVault(全盘加密)。
  • 绝不要使用Pastebin等公共服务存储敏感代码或数据。
  • 仅从官方商店安装浏览器扩展;尽量减少扩展的使用。