This is an app which demonstrates the use of JWT (token) -based security implementation in SpringBoot framework
Please use the Read-Only protocol to Clone the repository unless your are one of the maintainers:
git clone git://github.roving.com/ES/springboot-jwt-auth.git
Once the application is running then you can view the REST Web Service API endpoints in Swagger UI from the browser by accessing : http://localhost:5000/swagger-ui.html .
Once the application is running then you can demo it by using the following test procedure.
Issue GET request with no token (i.e., no Authorization header is specified). This results in 403 status.
curl http://localhost:5000/taskscurl -i -H "Content-Type: application/json" -X POST -d '{ "username": "smysore", "password": "smysore123" }' http://localhost:5000/users/sign-upcurl -i -H "Content-Type: application/json" -X POST -d '{ "username": "smysore", "password": "smysore123" }' http://localhost:5000/loginIn the generated response, Authorization header will be present containing the JSON Web Token (JWT) as a Bearer token.
In the request, pass the Authorization header with the JWT as Bearer token. This is the JWT that was generated from the previous step
curl -H "Authorization: Bearer JWTOKEN” -H "Content-Type: application/json" -X POST -d '{
"description": “Take the car for repair”
}' http://localhost:5000/taskscurl -H "Authorization: Bearer JWTOKEN” -H "Content-Type: application/json" -X POST -d '{
"description": “Take the car for repair”
}' http://localhost:5000/taskscurl -H "Authorization: Bearer JWTOKEN” http://localhost:5000/tasksFollowing is a sample request that is sending a JWT in Authorization header
curl -H "Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqb2UiLCJleHAiOjE1MzY2MDMwOTN9.eTsovcPk2nmEO186nM4TrIuPz6DyyTVEXUeVwOi2CqyUpw_1dhM6ZOps38shA6arHBp4nJ4u4tpqfPBHXAkJpw” http://localhost:5000/tasks