/spring-boot-examples-jwt-auth

Examples on how to secure a REST API using a JWT token.

Primary LanguageJavaApache License 2.0Apache-2.0

spring-boot-examples-jwt-auth

Examples on how to secure a REST API using a JWT token.

  1. First, set up a minimalistic Spring Boot app (pom.xml,ExampleApplication.java, ExampleController.java).
  2. Test the endpoint at localhost:8080/example/hello
  3. Second, add the security dependency (pom.xml) and the security config (application.yaml, JwtTokenFilter.java, SecurityConfig.java).
  4. Restart the app. Access to localhost:8080/example/hello should be forbidden now. Next, send your tooken in the request header and try again.