スキル一覧に戻る
joaquimscosta

spring-boot-security

by joaquimscosta

3🍴 0📅 2026年1月24日
GitHubで見るManusで実行

SKILL.md


name: spring-boot-security description: Spring Security 7 implementation for Spring Boot 4. Use when configuring authentication, authorization, OAuth2/JWT resource servers, method security, or CORS/CSRF. Covers the mandatory Lambda DSL migration, SecurityFilterChain patterns, @PreAuthorize, and password encoding. For testing secured endpoints, see spring-boot-testing skill.

Spring Security 7 for Spring Boot 4

Implements authentication and authorization with Spring Security 7's mandatory Lambda DSL.

Critical Breaking Changes

Removed APIReplacementStatus
and() methodLambda DSL closuresRequired
authorizeRequests()authorizeHttpRequests()Required
antMatchers()requestMatchers()Required
WebSecurityConfigurerAdapterSecurityFilterChain beanRequired
@EnableGlobalMethodSecurity@EnableMethodSecurityRequired

Core Workflow

  1. Create SecurityFilterChain bean → Configure with Lambda DSL
  2. Define authorization rulesauthorizeHttpRequests() with requestMatchers()
  3. Configure authentication → Form login, HTTP Basic, or OAuth2
  4. Add method security@EnableMethodSecurity + @PreAuthorize
  5. Handle CORS/CSRF → Configure for REST APIs

Quick Patterns

See EXAMPLES.md for complete working examples including:

  • REST API Security with JWT/OAuth2 (Java + Kotlin)
  • Form Login with Session Security and CSRF
  • Method Security with @PreAuthorize and SpEL
  • CORS Configuration for cross-origin APIs
  • Password Encoder (Argon2 for Security 7)

Spring Boot 4 Specifics

  • Lambda DSL is mandatory (no and() chaining)
  • Argon2 password encoder: Argon2PasswordEncoder.defaultsForSpring7()
  • CSRF for SPAs: CookieCsrfTokenRepository.withHttpOnlyFalse()
  • @EnableMethodSecurity replaces @EnableGlobalMethodSecurity

Detailed References

Anti-Pattern Checklist

Anti-PatternFix
Using and() chainingUse Lambda DSL closures
antMatchers()Replace with requestMatchers()
authorizeRequests()Replace with authorizeHttpRequests()
CSRF disabled without JWTKeep CSRF for session-based auth
Hardcoded credentialsUse environment variables or Secret Manager
permitAll() on sensitive endpointsAudit all permit rules
Missing authenticated() defaultEnd with .anyRequest().authenticated()

Critical Reminders

  1. Lambda DSL is mandatory — No more and() chaining in Security 7
  2. Order matters — More specific requestMatchers before general ones
  3. CSRF for sessions — Only disable for stateless JWT APIs
  4. Method security needs enabling — Add @EnableMethodSecurity
  5. Test security configuration — Use @WithMockUser and JWT test support (see spring-boot-testing)

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です