rrezartprebreza/spring-boot-skills / skills/spring-boot-3/spring-security-jwt
spring-security-jwt
VerifiedUse when an application issues and validates its own first-party JWT access and refresh tokens, including authentication filters, password encoding, RBAC, and method security. For JWTs issued by Keycloak, Auth0, Okta, Cognito, or another authorization server, use oauth2-resource-server.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.5 KB |
| agents/openai.yaml | config | 205 B |
| examples/bad-security-config.java | other | 1.4 KB |
| examples/good-security-config.java | other | 4.0 KB |
| templates/JwtAuthenticationFilter.java | other | 3.7 KB |
| templates/JwtService.java | other | 2.9 KB |
| templates/SecurityConfig.java | other | 4.0 KB |
examples/bad-security-config.java
View on GitHub// BAD — deprecated API, session-based, hardcoded secret, missing method security
@Configuration
@EnableWebSecurity // missing @EnableMethodSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter { // deprecated since Spring Security 5.7
@Autowired // field injection
private JwtAuthenticationFilter jwtAuthFilter;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable() // old chaining API, not lambda DSL
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED) // should be STATELESS for JWT
.and()
.authorizeRequests() // deprecated — use authorizeHttpRequests
.antMatchers("/api/**").authenticated() // antMatchers deprecated — use requestMatchers
.and()
.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder(); // default strength 10, should use 12
}
// secret hardcoded as string literal — should be in environment variable
private static final String SECRET = "mySecretKey12345678901234567890123456";
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |