This sample application shows how to develop a Restful api with SpringBoot and secure it using Spring Security via JSON Web Tokens.
- Make sure you have gradle installed on your system and an IDE. If you don't have an IDE don't worry you can still follow with a text editor and the terminal.
- Make sure you have Java 10 installed on your system. Get it here
- Clone the repository using the command
git clone https://github.com/Leandromaro/Auth0-Spring-Security-Example.git
- Run
gradle bootrun
to build and run the project or run the project from your ide(make sure you build it before running)
- HTTP 403 Forbidden status is expected
- curl http://localhost:8080/tasks
- curl -H "Content-Type: application/json" -X POST -d '{ "username": "admin", "password": "password" }' http://localhost:8080/users/sign-up
- curl -i -H "Content-Type: application/json" -X POST -d '{ "username": "admin", "password": "password" }' http://localhost:8080/login
- curl -H "Content-Type: application/json"
-H "Authorization: Bearer xxx.yyy.zzz"
-X POST -d '{ "description": "Buy watermelon" }' http://localhost:8080/tasks
- curl -H "Authorization: Bearer xxx.yyy.zzz" http://localhost:8080/tasks