r/SpringBoot • u/AMATERASU_001 • Feb 06 '26
Discussion Custom Spring Boot Starter for JWT Authentication
I created an open-source Spring Boot starter for seamless JWT authentication integration. This starter provides plug-and-play JWT token generation, validation, and request filtering with minimal configuration. i want feedback on this and want to improve it more so that setting up JWT auth in spring should be piece of cake.
Here is github Link :- Official Github repository
PS:- People who are advising in comments that you should not use these old jwt traditional methods,as these are irrelevant now , but thing is i am sharing what i have built from my sense of knowledge and problem i faced while learning basics of spring security, and not to contradict any technology that is way more better than my project, it's just sharing knowledge with people and learning. ✌🏻✌🏻
9
u/ParthoKR Feb 06 '26
It’s saddening that people still opt for the hard way to configure jwts.
Do we really need jwt? It only comes handy for distributed systems where stateless tokens make sense. If it’s a monolith, opaque tokens are just simpler.
In distributed environments, jwt is the first thing you would reach for.
You have a couple of servers with resources and its apis need to be protected? Just add spring’s oauth2 resource server in your pom/gradle and configure it pointing to the jwks endpoint of your idp.
You wanna provision tokens and validate? Use some authorization server.
We have so many options for production grade idp with authn/authz like auth0, aws cognito or even open source alternatives like keycloak, zitadel, authentik to name a few.
If you really wanna build auth server, use spring’s starter for authorization server. You can easily wrap up a functional authn/authz server that exposes jwks as well as introspection endpoint for external resource servers to reach out.
3
u/carlashnikov_92 Feb 06 '26
Ffs people, please, for the love of god, stop using that custom JWT auth with self signed tokens!!!
There are much better ways, one of them is the default Spring Security mechanism, which you can see in this video: https://m.youtube.com/watch?v=AE_Srj6r4Rc&pp=ygUTc3ByaW5nIHNlY3VyaXR5IHNwYQ%3D%3D
In that same video, Spring Auth Server is shown as an alternative, using the BFF pattern.
Alternatively, if you really insist on using self signed JWTs, at least stop using 3rd party libs and creating an own JwtFilter, cause guess what? Spring already supports that: https://m.youtube.com/watch?v=KYNR5js2cXE&pp=ygUMZGFuIHZlZ2Egand0
When are amateurs who don’t work as professionals gonna stop writing Medium blog posts selling half assed knowledge, when the spring docs contain everything you have to know?
2
u/Disastrous-Topic6930 Feb 06 '26
Looks good at a first glimpse! Gonna try it out in a project soon :)
2
u/New_Manager2741 Feb 06 '26
Great! Gonna try this.
1
u/Known_Bookkeeper2006 Feb 06 '26
This maybe a stupid question but can you tell me if like i just add the dependency into my spring boot project then all the necessary dependencies would come in including jjwt dependencies? And now i just need to set few things and im good to go?
1
u/naturalizedcitizen Feb 07 '26
Production ready??
Lots of enterprises must be stupid to use Okta, Cognito, etc.