- First, set up a minimalistic Spring Boot app (
pom.xml
,ExampleApplication.java
,ExampleController.java
). - Test the endpoint at localhost:8080/example/hello
- Second, add the security dependency (
pom.xml
) and the security config (application.yaml
,JwtTokenFilter.java
,SecurityConfig.java
). - Restart the app. Access to localhost:8080/example/hello should be forbidden now. Next, send your tooken in the request header and try again.
kerner1000/spring-boot-examples-jwt-auth
Examples on how to secure a REST API using a JWT token.
JavaApache-2.0