springboot-security
Java Spring Boot 服务中关于身份验证/授权、验证、CSRF、密钥、标头、速率限制和依赖安全的 Spring Security 最佳实践。
Skill by Luohaothu
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/luohaothu-springboot-security
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/springboot-security
What's inside
- Skill name
springboot-security- Description
- Java Spring Boot 服务中关于身份验证/授权、验证、CSRF、密钥、标头、速率限制和依赖安全的 Spring Security 最佳实践。
- License
- MIT
- Instructions
- 116 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Spring Boot 安全审查
在添加身份验证、处理输入、创建端点或处理密钥时使用。
## 身份验证
* 优先使用无状态 JWT 或带有撤销列表的不透明令牌
* 对于会话,使用 `httpOnly`、`Secure`、`SameSite=Strict` cookie
* 使用 `OncePerRequestFilter` 或资源服务器验证令牌
```java
@Component
public class JwtAuthFilter extends OncePerRequestFilter {
private final JwtService jwtService;
public JwtAuthFilter(JwtService jwtService) {
this.jwtService = jwtService;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain chain) throws ServletException, IOException {
String header = request.getHeader(HttpHeaders.AUTHORIZATION);
if (header != null && header.startsWith("Bearer ")) {
String token = header.substring(7);
Authentication auth = jwtService.authenticate(token);
SecurityContextHolder.getContext().setAuthentication(auth);
}
chain.doFilter(request, response);
}
}
```
## 授权
* 启用方法安全:`@EnableMethodSecurity`
* 使用 `@PreAuthorize("hasRole('ADMIN')")` 或 `@PreAuthorize("@authz.canEdit(#id)")`
* 默认拒绝;仅公开必需的 scope
## 输入验证
* 在控制器上使用带有 `@Valid` 的 Bean 验证
* 在 DTO 上应用约束:`@NotBlank`、`@Email`、`@Size`、自定义验证器
* 在渲染之前使用白名单清理任何 HTML
## SQL 注入预防
* 使用 Spring Data 存储库或参数化查询
* 对于原生查询,使用 `:param` 绑定;切勿拼接字符串
## CSRF 保护
* 对于浏览器会话应用程序,保持 CSRF 启用;在表单/头中包含令牌
* 对于使用 Bearer 令牌的纯 API,禁用 CSRF 并依赖无状态身份验证
```java
http
.csrf(csrf -> csrf.disable())
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
```
## 密钥管理
* 源代码中不包含密钥;从环境变量或 vault 加载
* 保持 `application.yml` 不包含凭据;使用占位符
* 定期轮换令牌和数据库凭据
## 安全头
```java
http
.headers(headers -> headers
.contentSecurityPolicy(csp -> csp
.policyDirectives("default-src 'self'"))
.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)
.xssProtection(Customizer.withDefaults())
.referrerPolicy(rp -> rp.policy(ReferrerPolicyHeaderWriter.ReferrerPolicy.NO_REFERRER)));
```
## 速率限制
* 在昂贵的端点上应用 Bucket4j 或网关级限制
* 记录突发流量并告警;返回 429 并提供重试提示
## 依赖项安全
* 在 CI 中运行 OWASP Dependency Check / Snyk
* 保持 Spring Boot 和 Spring Security 在受支持的版本
* 对已知 CVE 使构建失败
## 日志记录和 PII
* 切勿记录密钥、令牌、密码或完整的 PAN 数据
* 擦除敏感字段;使用结构化 JSON 日志记录
## 文件上传
* 验证大小、内容类型和扩展名
* 存储在 Web 根目录之外;如果需要则进行扫描
## 发布前检查清单
* \[ ] 身份验证令牌已验证并正确过期
* \[ ] 每个敏感路径都有授权守卫
* \[ ] 所有输入都已验证和清理
* \[ ] 没有字符串拼接的 SQL
* \[ ] CSRF 策略适用于应用程序类型
* \[ ] 密钥已外部化;未提交任何密钥
* \[ ] 安全头已配置
* \[ ] API 有速率限制
* \[ ] 依赖项已扫描并保持最新
* \[ ] 日志不包含敏感数据
**记住**:默认拒绝、验证输入、最小权限、优先采用安全配置。From Luohaothu/everything-codex, MIT.
More from Luohaothu/everything-codex
- 0.493score
architect
Luohaothu
Software architecture specialist for system design, scalability, and technical decision-making.
SkillDFreshness: D★ 26Claude Code +9 - 0.493score
build-fix
Luohaothu
Build and compilation error resolution specialist.
SkillDFreshness: D★ 26Claude Code +9 - 0.490score
code-review
Luohaothu
Expert code review for quality, security, and maintainability.
SkillDFreshness: D★ 26Claude Code +9 - 0.490score
checkpoint
Luohaothu
Create or verify workflow checkpoints using git commits and state tracking.
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
tdd-workflow
Luohaothu
在编写新功能、修复错误或重构代码时使用此技能。强制执行测试驱动开发,包含单元测试、集成测试和端到端测试,覆盖率超过80%。
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-tdd
Luohaothu
使用JUnit 5、Mockito、MockMvc、Testcontainers和JaCoCo进行Spring Boot的测试驱动开发。适用于添加功能、修复错误或重构时。
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-patterns
Luohaothu
Spring Boot 架构模式、REST API 设计、分层服务、数据访问、缓存、异步处理和日志记录。适用于 Java Spring Boot 后端工作。
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
jpa-patterns
Luohaothu
Spring Boot中的JPA/Hibernate实体设计、关系、查询优化、事务、审计、索引、分页和连接池模式。
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
postgres-patterns
Luohaothu
基于Supabase最佳实践的PostgreSQL数据库模式,用于查询优化、架构设计、索引和安全。
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
eval-harness
Luohaothu
克劳德代码会话的正式评估框架,实施评估驱动开发(EDD)原则
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
strategic-compact
Luohaothu
建议在逻辑间隔处进行手动上下文压缩,以在任务阶段中保留上下文,而非任意的自动压缩。
SkillDFreshness: D★ 26Claude Code +9 - 0.484score
continuous-learning-v2
Luohaothu
基于本能的学习系统,通过钩子观察会话,创建具有置信度评分的原子本能,并将其演化为技能/命令/代理。
SkillDFreshness: D★ 26Claude Code +9
Signals
- Stars
- 26
- Forks
- 5
- Open issues
- 0
- Last commit (this folder)
- Feb 5, 2026 (8 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Luohaothu/everything-codex
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Luohaothu
- 0.493score
build-fix
Luohaothu
Build and compilation error resolution specialist.
SkillDFreshness: D★ 26Claude Code +9 - 0.493score
architect
Luohaothu
Software architecture specialist for system design, scalability, and technical decision-making.
SkillDFreshness: D★ 26Claude Code +9 - 0.490score
code-review
Luohaothu
Expert code review for quality, security, and maintainability.
SkillDFreshness: D★ 26Claude Code +9 - 0.490score
checkpoint
Luohaothu
Create or verify workflow checkpoints using git commits and state tracking.
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-patterns
Luohaothu
Spring Boot 架构模式、REST API 设计、分层服务、数据访问、缓存、异步处理和日志记录。适用于 Java Spring Boot 后端工作。
SkillDFreshness: D★ 26Claude Code +9 - 0.487score
springboot-tdd
Luohaothu
使用JUnit 5、Mockito、MockMvc、Testcontainers和JaCoCo进行Spring Boot的测试驱动开发。适用于添加功能、修复错误或重构时。
SkillDFreshness: D★ 26Claude Code +9
Cite this page
springboot-security skill. Agent Mart. https://agentmart.dev/skills/luohaothu-springboot-security (last updated 2026-10-24)