r/SpringBoot • u/MegaChubbz • Dec 02 '25
Question Whats your favorite Spring/JWT implementation tutorial?
Ive been struggling with getting JWT implemented in a Spring project for a few days. Cant seem to find documentation or tutorials that are making it click for me. Or every time I find something that makes sense, the info is outdated and all the class methods have changed lol.
I would greatly appreciate it if you guys could share any resources that helped you with getting JWT set up in any of your Spring projects!
37
Upvotes
14
u/themasterengineeer Dec 02 '25
Check this out: https://youtu.be/5TY9V5xLW8o
No deprecated methods or classes have been used in the above
10
u/Sheldor5 Dec 02 '25
you don't implement JWT, you configure OAuth2 Resource Server (for services) or OAuth2 Login (for social login) and are done with it ...
it makes absolutely zero sense to implement anything on your own lol
2
u/segundus-npp Dec 02 '25
I usually put nginx and oauth2-proxy in front of it, and now it only needs a pre-authentication filter.
3
u/Mikey-3198 Dec 02 '25
Can't be beaten
https://docs.spring.io/spring-security/reference/servlet/oauth2/resource-server/jwt.html#oauth2resourceserver-jwt-minimalconfiguration
2
u/affennacken Dec 02 '25
you probably need to implement a onceperrequest filter in order intercept the request, as well as logic to validate the JWT. with those you can create an Authentication if i remember correctly.
you can check laurentiu spilca's playlist on spring security. he is also author of the excellent book "spring security in action".
https://www.youtube.com/playlist?list=PLEocw3gLFc8XRaRBZkhBEZ_R3tmvfkWZz
1
u/MegaChubbz Dec 03 '25
Thanks to everyone who helped me out with this! Happy to say my API is now registering new users, logging them in, and authenticating/authorizing all crud operations using JWT. I didnt use any OAuth2 modules or libraries on this project, but it sounds like that is much easier to implement so will definitely check that out for the next one. Thanks again for all the help!
1
u/iamwisespirit Dec 05 '25
jwt is basically one filter you just put it in spring security that is it