Spring Security best practices for authn/authz, validation, CSRF, secrets, headers, rate limiting, and dependency security in Java Spring Boot services.
68
52%
Does it follow best practices?
Impact
96%
1.29xAverage score across 3 eval scenarios
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./docs/ja-JP/skills/springboot-security/SKILL.mdThe canonical home for this skill is springboot-security in affaan-m/everything-claude-code
認証の追加、入力処理、エンドポイント作成、またはシークレット処理時に使用します。
httpOnly、Secure、SameSite=Strict クッキーを使用OncePerRequestFilter またはリソースサーバーでトークンを検証@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)") を使用@Valid を使用してコントローラーでBean Validationを使用@NotBlank、@Email、@Size、カスタムバリデーター:param バインディングを使用し、文字列を連結しないhttp
.csrf(csrf -> csrf.disable())
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS));application.yml を認証情報から解放し、プレースホルダーを使用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)));注意: デフォルトで拒否し、入力を検証し、最小権限を適用し、設定によるセキュリティを優先します。
06c5e11
Canonical home
since Feb 27, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.