DEV Community

Seydou CISSE
Seydou CISSE

Posted on

Stop Rewriting JWT Code for Every Spring Boot Project

Every time I started a new Spring Boot project, I found myself writing the same JWT authentication setup over and over again. Configure Spring Security, set up token generation, validation, blacklisting.

So, I built JWT Spring Boot Starter to handle it automatically.

What It Does

This starter takes care of JWT authentication so you don’t have to. Just add the dependency, configure a few properties, and voila—you’re ready to go.

  • Token Generation & Validation: Automatically creates and verifies JWT tokens.

  • Token Blacklisting: Easily invalidate tokens with a built-in (and optionally replaceable) in-memory blacklist.

  • Custom Claims & Token Refresh: Supports adding custom claims and automatic token refresh logic.

Quick Start Guide

First, add the dependency in your pom.xml:

<dependency>
    <groupId>io.github.seydoucisse</groupId>
    <artifactId>jwt-spring-boot-starter</artifactId>
    <version>0.1.0</version>
</dependency>
Enter fullscreen mode Exit fullscreen mode

Then, configure your application.yml:


jwt:
  secret: your-very-secure-secret-key-that-is-64-characters
  issuer: your-app-name
Enter fullscreen mode Exit fullscreen mode

And finally, define your UserDetailsService:


@Service
public class MyUserDetailsService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        // Add with your user lookup logic
    }
}
Enter fullscreen mode Exit fullscreen mode

That’s it! The starter handles token generation, validation, blacklisting, and integrates seamlessly with Spring Security.

Why Use It?

  • No need to write JWT auth from scratch
  • Works out of the box with Spring Security
  • Customizable token properties and security settings
  • Supports token blacklisting and refresh tokens

If you’re tired of rewriting the same jwt-based authentication in your Spring Boot app, give JWT Spring Boot Starter a shot!

Check it out the full documentation on jwt-spring-boot-starter.
Feel free to open an issue or submit a pull request.

Top comments (0)

Great read:

Is it Time to go Back to the Monolith?

History repeats itself. Everything old is new again and I’ve been around long enough to see ideas discarded, rediscovered and return triumphantly to overtake the fad. In recent years SQL has made a tremendous comeback from the dead. We love relational databases all over again. I think the Monolith will have its space odyssey moment again. Microservices and serverless are trends pushed by the cloud vendors, designed to sell us more cloud computing resources.

Microservices make very little sense financially for most use cases. Yes, they can ramp down. But when they scale up, they pay the costs in dividends. The increased observability costs alone line the pockets of the “big cloud” vendors.

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay