Spring Security JWT for Spring Boot 4

    by Rrezart Prebreza

    1

    Production-grade first-party JWT authentication guidance for Spring Boot 4 and Spring Security 7.

    Free

    4 usesSecurity scanned

    Works with the AI Agents you already use

    Spring Security JWT for Spring Boot 4

    Example session with this skill installed

    Add secure first-party JWT access and refresh token authentication to this Spring Boot 4 API. Use the project's existing user model, protect /api/orders/, keep /api/auth/ public, and add method-level authorization for administrators.

    • Read your context and instructions
    • Compiled the spring security jwt

    Security implementation plan

    The agent first inspects the existing authentication model, dependency management, controllers, and security tests. It distinguishes a first-party token service from an external OAuth2 issuer and preserves the project's current account and role model.

    Deliverables

    • A Spring Security 7 SecurityFilterChain using the lambda DSL and current request-matcher APIs.
    • A JwtService that validates signature, issuer, audience, expiration, and token type before trusting claims.
    • A once-per-request authentication filter that rejects malformed credentials cleanly and does not authenticate disabled or missing accounts.
    • Access and refresh token separation, bounded expiration, password encoding, role mapping, and method-security support.
    • Focused tests for public routes, missing tokens, invalid signatures, expired tokens, role restrictions, and refresh-token misuse.

    Review findings

    The skill flags obsolete Spring Security APIs, hard-coded signing secrets, unvalidated claims, refresh tokens accepted as access tokens, broad permit rules, incorrect filter ordering, and exception handling that leaks internal details. It adapts templates to the repository rather than replacing established contracts.

    Next steps

    Run the project's authentication and authorization tests, verify key rotation and secret delivery in the deployment environment, and confirm that logs and telemetry never contain raw tokens.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Build and review first-party JWT authentication for Spring Boot 4 and Spring Security 7. The skill covers access and refresh tokens, authentication filters, password encoding, role-based authorization, method security, current request-matcher APIs, and common insecure or obsolete patterns. It includes implementation examples and reusable Java templates.

    Use this when the application issues and validates its own JWTs. For tokens issued by Keycloak, Auth0, Okta, Cognito, or another authorization server, use an OAuth2 resource-server approach instead.

    Open source under the MIT License. GitHub is the primary source: https://github.com/rrezartprebreza/spring-boot-skills

    Requires Spring Boot 4.x / Spring Security 7. Does not include a database implementation for refresh token rotation or revocation. First-party JWTs only.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    4 uses

    Times used to date

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 2 months ago

    • Free with an Agensi account

    Permissions

    No special permissions declared or detected

    Listed2 months ago

    What's inside

    Creator

    Rrezart Prebreza

    Rrezart Prebreza

    3 skills on Agensi

    Senior software engineer with 10+ years of experience designing and building production-grade systems across fintech, banking, and enterprise software, collaborating with international remote teams in the US, Switzerland, and Germany. My core expertise is in backend engineering with Java, Spring Boot, and .NET, building scalable, secure, and maintainable systems for real business environments. I work extensively with Spring MVC, Spring Security, Spring Data JPA/Hibernate, REST APIs, RabbitMQ, Docker, Keycloak, and Duo integration, with strong experience in authentication, enterprise workflows, and service-based architectures. I also build AI-enabled backend solutions using Spring AI, LLM integrations, RAG pipelines, and prompt engineering, helping turn modern AI capabilities into practical business applications. My experience includes designing and integrating RESTful APIs, XML services, SDMX-based data exchange systems, and enterprise reporting solutions. I have worked with PostgreSQL, MySQL, Oracle, Microsoft SQL Server, and MariaDB, along with tools such as Liquibase for database versioning and deployment. On the frontend side, I have experience with Angular, React, Thymeleaf, JSP, HTML, CSS, JavaScript, and TypeScript, allowing me to contribute across full-stack projects when needed. In addition to industry work, I have over 6 years of teaching experience as a lecturer at Universum International College, where I teach Java, Spring Boot, Web Services, Data Structures, and Software Engineering. I am also certified in Digitally Enhanced, Blended, and Online Learning by Cintana Education and serve as an academic reviewer for the International Journal of Computing and Digital Systems. I enjoy building secure, scalable, and modern software solutions that combine strong engineering practices with practical innovation. Tech Stack: Java, Spring Boot, .NET, Spring AI, Spring Security, Spring Data JPA, Hibernate, REST APIs, RabbitMQ, Docker, Keycloak, Duo, PostgreSQL, MySQL, Oracle, SQL Server, MariaDB, Liquibase, JWT, Angular, React, Thymeleaf, JSP, JavaScript, TypeScript, Power BI, Jaspersoft, GitHub, Bitbucket, JIRA, CI/CD, Agile, Scrum

    Frequently Asked Questions

    This skill provides specific guidance and templates for building a custom, production-ready JWT authentication system within Spring Boot 4 applications, bypassing the complexity of external identity providers.

    It is optimized for Spring Boot 4 and Spring Security 7, focusing on the latest API changes, request-matcher syntax, and modern security best practices.

    No, this skill is specifically designed for first-party authentication where your application issues its own tokens; for Keycloak, Okta, or Auth0, you should use an OAuth2 resource-server configuration.

    You will receive comprehensive implementation guidance, Java code templates for filters and token providers, and a checklist to identify and fix obsolete or insecure security patterns.

    The skill covers access and refresh token logic, secure password encoding, and granular role-based authorization using both URL-based and method-level security.

    Yes, this skill is open-source under the MIT License, and the primary source code and documentation can be found on the project's official GitHub repository.

    New in APIs & Backend

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.

    Free