Spring Security already ships everything you need. Here's the whole setup in four small classes.
Search "Spring Boot JWT" and most tutorials give you the same recipe. Add the jjwt library. Write a OncePerRequestFilter . Pull the token out of the Authorization header by hand, parse it, catch the exceptions, and put the user into the SecurityContext yourself.
That works, but it leaves you owning security code that Spring Security already has, tested and maintained by its own team.
Spring Security has supported JWT for years through its OAuth2 Resource Server module.…