Skip to content

RSundaresh/test_ci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

springboot-jwt-

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

Viewing the REST Web Service API Endpoint

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 .

Testing this application

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/tasks

Register a new user.

curl -i -H "Content-Type: application/json" -X POST -d '{ "username": "smysore", "password": "smysore123" }' http://localhost:5000/users/sign-up

Login with user credentials to authenticate and generate token.

curl -i -H "Content-Type: application/json" -X POST -d '{ "username": "smysore", "password": "smysore123" }' http://localhost:5000/login

In the generated response, Authorization header will be present containing the JSON Web Token (JWT) as a Bearer token.

Issue a POST request, passing valid token to create a new task.

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/tasks

Issue a POST request, passing valid token to create a new task.

curl -H "Authorization: Bearer JWTOKEN” -H "Content-Type: application/json" -X POST -d '{
 "description": “Take the car for repair”
}'  http://localhost:5000/tasks

Issue GET request, passing valid token to retrieve tasks.

curl -H "Authorization: Bearer JWTOKEN” http://localhost:5000/tasks

Following is a sample request that is sending a JWT in Authorization header

curl -H "Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqb2UiLCJleHAiOjE1MzY2MDMwOTN9.eTsovcPk2nmEO186nM4TrIuPz6DyyTVEXUeVwOi2CqyUpw_1dhM6ZOps38shA6arHBp4nJ4u4tpqfPBHXAkJpw” http://localhost:5000/tasks

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages