Spring boot Security + JWT Demo Example

Here I have created a maven project and configured JSON WEB TOKEN(JWT) with Spring Boot.

JWT Will Perform the below 2 operations:

1. Generate JWT Token — We Expose a POST API on /authenticate Endpoint. And Passing the correct username and password to generate a JSON Web Token(JWT).

JWT Token Generate with Valid credentials :

Make a POST request with URL http://localhost:8089/authenticate. The body should have a valid username and password. Here I used username: “ruhul” and password: “password”. Please make sure that the body should be in JSON format. If the username and password are valid then it will return a token and success Response with 200 Status code. An example is below :

Validate JWT Token & Make Rest API call :

Try to access the URL http://localhost:8089/testuri using the above-generated token in the header as Bearer Token. If the Authorization Bearer token is valid it will return a valid response.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
A.T.M Ruhul Amin

Tech Lead | Java | Spring Boot | Python | React | Angular | Serverless | AWS Certified | GitHub Link : https://github.com/ruhulmus