SKILL

springboot-security

Spring Security best practices for authentication/authorization, validation, CSRF, secrets, headers, rate limiting, and dependency security in Java Spring Boot services.

Machine translation
Read the original Chinese text

Java Spring Boot 服务中认证/授权、验证、CSRF、密钥、标头、速率限制和依赖安全性的 Spring Security 最佳实践。

Target: Cloud, operations & security. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Chinese text

Topics in the source

  • Spring Boot 安全审查
  • 何时激活
  • 身份验证
  • 授权
  • 输入验证
  • SQL 注入预防
  • 密码编码
  • CSRF 保护

在添加身份验证、处理输入、创建端点或处理密钥时使用。 添加身份验证(JWT、OAuth2、基于会话) 实现授权(@PreAuthorize、基于角色的访问控制) 验证用户输入(Bean Validation、自定义验证器) 配置 CORS、CSRF 或安全标头 管理密钥(Vault、环境变量) 添加速率限制或暴力破解防护 扫描依赖项以查找 CVE 优先使用无状态 JWT 或带有撤销列表的不透明令牌 对于会话,使用 httpOnly、Secure、SameSite=Strict cookie 使用 OncePerRequestFilter 或资源服务器验证令牌 启用方法安全:@EnableMethodSecurity 使用 @PreAuthorize("hasRole('ADMIN')") 或 @PreAuthorize("@authz.canEdit(#id)") 默认拒绝;仅公开必需的 scope 在控制器上使用带有 @Valid 的 Bean 验证 在 DTO 上应用约束:@NotBlank、@Email、@Size、自定义验证器 在渲染之前使用白名单清理任何 HTML 使用 Spring Data 存储库或参数化查询 对于原生查询,使用 :param 绑定;切勿拼接字符串 始终使用 BCrypt 或 Argon2 哈希密码——切勿存储明文 使用 PasswordEncoder Bean,而非手动哈希 对于浏览器会话应用程序,保持 CSRF 启用;在表单/头中包含令牌 对于使用 Bearer 令牌的纯 API,禁用 CSRF 并依赖无状态身份验证 源代码中不包含密钥;从环境变量或 vault 加载 保持 application.yml 不包含凭据;使用占位符 定期轮换令牌和数据库凭据 在安全过滤器级别配置 CORS,而非按控制器配置 限制允许的来源——在生产环境中切勿使用 在昂贵的端点上应用 Bucket4j 或网关级限制 记录突发流量并告警;返回 429 并提供重试提示 在 CI 中运行 OWASP Dependency Check / Snyk 保持 Spring Boot 和 Spring Security 在受支持的版本 对已知 CVE 使构建失败 切勿记录密钥、令牌、密码或完整的 PAN 数据 擦除敏感字段;使用结构化 JSON 日志记录 验证大小、内容类型和扩展名 存储在 Web 根目录之外;如果需要则进行扫描 \[ ] 身份验证令牌已验证并正确过期 \[ ] 每个敏感路径都有授权守卫 \[ ] 所有输入都已验证和清理 \[ ] 没有字符串拼接的 SQL \[ ] CSRF 策略适用于应用程序类型 \[ ] 密钥已外部化;未提交任何密钥 \[ ] 安全头已配置 \[ ] API 有速率限制 \[ ] 依赖项已扫描并保持最新 \[ ] 日志不包

This is an excerpt. Refer to the complete source and its current requirements.

Source repository
affaan-m/ECC
Source file
docs/zh-CN/skills/springboot-security/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Requirements

  • Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.

A small first task

先阅读原作者说明,再决定是否在自己的 AI 工具中使用。

Instructions for your AI tool

Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:42.633Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.