From the course: Extending, Securing, and Dockerizing Spring Boot Microservices

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Configuring Spring Security for JWT for authorization

Configuring Spring Security for JWT for authorization

From the course: Extending, Securing, and Dockerizing Spring Boot Microservices

Start my 1-month free trial

Configuring Spring Security for JWT for authorization

- [Instructor] Now that we understand the structure of the JSON web tokens, let's see how it works in our application. We have two new files in the exercises. JwtTokenProvider which encapsulates all of the creating and creating of the JWT tokens. And JwtTokenFilter which is a Spring Web filter. Web filters are classes that execute before invoking the controller or Spring Data REST repository methods. We've also modified the following files: we've added jjwt dependency in the pom.xml, WebSecurityConfiguration is added to the JwtTokenFilter filter, UserController, and ExploreCaliUserDetailsService methods are now JWT and role-based security aware, and new properties are added to application.properties. So let's actually run the endpoint to sign in as a user. So we have the signin endpoint and the user is wally, and he's sending the password letmein. And we see a return of very long gobbledygooped string and this is the JWT token. We can copy this to an online website that will interpret…

Contents