/java-spring:java-security [review | jwt | oauth2 | method-security | cors] [Spring Boot version]from java-spring
Reviews or implements Spring Security configuration for JWT, OAuth2, method-level security, CORS, and CSRF in Spring Boot projects.
Ships in java-spring. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are a Spring Security specialist. Review existing security configuration or implement new security features for Spring Boot projects.
Quick OWASP vulnerability scan? Use
/java-security-checkinstead.
pom.xml / build.gradle:
jakarta.*, SecurityFilterChain bean, no WebSecurityConfigurerAdapter)javax.*, WebSecurityConfigurerAdapter still works but deprecated)spring-boot-starter-security is already on the classpath@Configuration + @EnableWebSecurity classesreview (default if no arg) → audit existing config, go to Step 3jwt → implement stateless JWT authentication, go to Step 4oauth2 → configure OAuth2 resource server or login, go to Step 5method-security → add method-level annotations, go to Step 6cors → configure CORS policy, go to Step 7Check for these issues and report each with file:line and severity:
CRITICAL
permitAll() on sensitive paths (/admin, /actuator, /internal)csrf().disable() on non-stateless APIs (stateful session apps need CSRF)@CrossOrigin(origins = "*") in production controllersHIGH
httpBasic() enabled on production APIs (use JWT or OAuth2)/actuator/**)@PreAuthorize or role checks on admin endpointsantMatchers / requestMatchers ordering issues (broad rules before specific ones)MEDIUM
BCryptPasswordEncoder strength below 10/login endpointUse the patterns in references/patterns.md to suggest fixes.
Use the templates in references/patterns.md (JWT section). Generate in this order:
Dependencies — add to pom.xml / build.gradle:
spring-boot-starter-oauth2-resource-server (uses built-in JWT support)jjwt-api, jjwt-impl, jjwt-jacksonSecurityConfig.java — SecurityFilterChain bean:
SessionCreationPolicy.STATELESS)/auth/**, secure everything elseJwtService.java — generate and validate tokens:
HS256 (symmetric) for simple cases, RS256 (asymmetric) for multi-servicesub (userId), iat, exp, rolesAuthController.java — /auth/login and /auth/refresh endpoints
AuthService.java — authenticate against UserDetailsService, issue tokens
Version notes:
spring-security-oauth2-resource-server JWT decoder — no manual filter neededOncePerRequestFilter manuallyFor resource server (API validates tokens from an external IdP):
spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: https://your-idp.example.com
For login (users log in via Google, GitHub, etc.):
spring:
security:
oauth2:
client:
registration:
google:
client-id: ${GOOGLE_CLIENT_ID}
client-secret: ${GOOGLE_CLIENT_SECRET}
Remind: never hardcode client secrets — use environment variables.
Enable with @EnableMethodSecurity (Spring Security 6) or @EnableGlobalMethodSecurity (5):
| Annotation | Use for |
|---|---|
@PreAuthorize("hasRole('ADMIN')") | Role-based access before method runs |
@PreAuthorize("hasAuthority('user:write')") | Fine-grained permission check |
@PreAuthorize("#userId == authentication.principal.id") | Owner-only access |
@PostAuthorize("returnObject.userId == authentication.principal.id") | Filter after return |
@Secured("ROLE_ADMIN") | Simple role check (legacy) |
Generate @PreAuthorize annotations for each controller method based on its sensitivity.
// Preferred: global CORS via SecurityFilterChain (Spring Security 6)
http.cors(cors -> cors.configurationSource(corsConfigurationSource()));
@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOrigins(List.of("https://app.example.com")); // never "*" in prod
config.setAllowedMethods(List.of("GET","POST","PUT","DELETE","OPTIONS"));
config.setAllowedHeaders(List.of("Authorization","Content-Type"));
config.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return source;
}
Flag @CrossOrigin(origins = "*") on controllers — replace with global config.
application.yml/auth/login endpoint is rate-limited (suggest Bucket4j or Spring's built-in)/java-security-check to verify no OWASP issues remain/java-security-checkjava-security-reviewer agent/java-testWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ducpm2303/claude-java-plugins --plugin java-spring9 skills in this plugin
/java-cacheUse when the user asks to add caching, configure Redis or Caffeine cache, use @Cacheable/@CacheEvict/@CachePut, optimize repeated database or API calls, or review existing Spring Boot cache configuration./java-crud/java-crud — Spring Boot CRUD GeneratorGenerates a complete Spring Boot CRUD feature (entity, repository, service, controller, DTOs, tests) in an existing project. Use when user asks to "add CRUD for", "generate entity", "create a feature for", "add REST endpoints for", "scaffold a feature", or "build CRUD for"./java-jpa/java-jpa — Spring Data JPA Deep ReviewOther plugins' skills for the same job