<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Seydou CISSE</title>
    <description>The latest articles on DEV Community by Seydou CISSE (@scisse).</description>
    <link>https://dev.to/scisse</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F839244%2Fedd57980-1490-49ed-bebb-32107757f681.png</url>
      <title>DEV Community: Seydou CISSE</title>
      <link>https://dev.to/scisse</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/scisse"/>
    <language>en</language>
    <item>
      <title>Stop Rewriting JWT Code for Every Spring Boot Project</title>
      <dc:creator>Seydou CISSE</dc:creator>
      <pubDate>Mon, 24 Mar 2025 15:04:47 +0000</pubDate>
      <link>https://dev.to/scisse/stop-rewriting-jwt-code-for-every-spring-boot-project-34o3</link>
      <guid>https://dev.to/scisse/stop-rewriting-jwt-code-for-every-spring-boot-project-34o3</guid>
      <description>&lt;p&gt;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. &lt;/p&gt;

&lt;p&gt;So, I built JWT Spring Boot Starter to handle it automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  What It Does
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Token Generation &amp;amp; Validation: Automatically creates and verifies JWT tokens.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Token Blacklisting: Easily invalidate tokens with a built-in (and optionally replaceable) in-memory blacklist.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Custom Claims &amp;amp; Token Refresh: Supports adding custom claims and automatic token refresh logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quick Start Guide
&lt;/h2&gt;

&lt;p&gt;First, add the dependency in your pom.xml:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;io.github.seydoucisse&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;jwt-spring-boot-starter&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;0.1.0&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, configure your application.yml:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;
&lt;span class="na"&gt;jwt&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;secret&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;your-very-secure-secret-key-that-is-64-characters&lt;/span&gt;
  &lt;span class="na"&gt;issuer&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;your-app-name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, define your UserDetailsService:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;
&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyUserDetailsService&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;UserDetailsService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;UserDetails&lt;/span&gt; &lt;span class="nf"&gt;loadUserByUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;UsernameNotFoundException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Add with your user lookup logic&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it! The starter handles token generation, validation, blacklisting, and integrates seamlessly with Spring Security.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Use It?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No need to write JWT auth from scratch&lt;/li&gt;
&lt;li&gt;Works out of the box with Spring Security&lt;/li&gt;
&lt;li&gt;Customizable token properties and security settings&lt;/li&gt;
&lt;li&gt;Supports token blacklisting and refresh tokens&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Check it out the full documentation on &lt;a href="https://seydoucisse.github.io/jwt-spring-boot-starter/" rel="noopener noreferrer"&gt;jwt-spring-boot-starter&lt;/a&gt;.&lt;br&gt;
Feel free to open an issue or submit a pull request.&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>jwt</category>
      <category>springsecurity</category>
    </item>
  </channel>
</rss>
