spring-boot-security-jwt

Implements JWT authentication and authorization for Spring Boot 3.5.x applications.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/412181-HerediaLara/ScaffoldingBE-FE --skill spring-boot-security-jwt-412181-heredialara
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: spring-boot-security-jwt
Source: https://github.com/412181-HerediaLara/ScaffoldingBE-FE/tree/main/BE/.agents/skills/spring-boot-security-jwt
Command: npx skills add https://github.com/412181-HerediaLara/ScaffoldingBE-FE --skill spring-boot-security-jwt-412181-heredialara

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Securing a Spring Boot REST API with stateless JWT authentication involves many moving parts—token generation, validation filters, refresh token rotation, and role-based access control—and getting any of them wrong creates security holes. This Skill provides complete, tested implementation patterns for Spring Security 6.x and JJWT 0.12.6 so you can set up authentication and authorization correctly. ## Core Features & Use Cases - Token Lifecycle Management: Generate access and refresh tokens with JJWT, implement refresh token rotation, revocation, and blacklisting via the jti claim. - Flexible Authentication Strategies: Support both Authorization: Bearer header and HttpOnly cookie-based authentication, plus OAuth2 login with Google and GitHub. - Fine-Grained Authorization: Apply RBAC and permission-based rules with @PreAuthorize, custom PermissionEvaluator, and role hierarchies. - Use Case: You are building a Spring Boot backend for a SPA and need stateless login, 15-minute access tokens, 7-day rotating refresh tokens stored in the database, and admin-only endpoints—this Skill walks you through every step from dependencies to security tests. ## Quick Start Ask the AI to implement JWT authentication with refresh token rotation and role-based access control in your Spring Boot 3.5.x project.

Frequently Asked Questions about spring-boot-security-jwt

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement JWT authentication in Spring Boot 3?

Add spring-boot-starter-security and the JJWT 0.12.6 artifacts, create a JwtService for token generation and validation, build a JwtAuthenticationFilter extending OncePerRequestFilter, and register it in a SecurityFilterChain bean with stateless session management.

How to implement refresh token rotation in Spring Security?

Store refresh tokens in the database with user_id, expiry_date, and revoked flags. On each /refresh call, verify the stored token, revoke it, and issue a new access and refresh token pair so old tokens cannot be reused.

Should I use Bearer header or HttpOnly cookie for JWT?

Use HttpOnly cookies for browser clients to protect against XSS token theft, and the Authorization Bearer header for mobile or API clients. In production, set Secure and SameSite=Lax or Strict attributes on cookies.

Does Spring Security 6 still support WebSecurityConfigurerAdapter?

No, WebSecurityConfigurerAdapter was removed in Spring Security 6.x. You must define SecurityFilterChain beans with the lambda DSL and replace @EnableGlobalMethodSecurity with @EnableMethodSecurity.

How do I test secured endpoints with MockMvc?

Use @SpringBootTest with @AutoConfigureMockMvc and spring-security-test. Verify unauthorized requests return 401, and use @WithMockUser(roles = "ADMIN") to simulate authenticated users with specific roles for authorized endpoint tests.

What are the security limitations of JWT tokens?

JWT claims are signed but not encrypted, so never store passwords or PII in them. Keep access token lifetimes short (5-15 minutes), use minimum 256-bit signing keys from environment variables, and validate exp, iss, and aud claims on every request.