Skip to content

pratik1507/Spring-Boot-Security-JWT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Spring-Boot-Security-JWT

This repository is related to spring boot security with JWT (JSON WEB TOKEN) .
In this project we will see how to configure InMemory user and JWT authentication using latest Spring Boot version 3.2.

Create new Spring Boot Project :

Go to spring initializer and create new project with dependencies
Add the following dependencies

For Web :

web-dep

For security :

security-dep

Lombok :

lambok

JWT :

jwt-dep

JWT Authentication Flow :

image

Output :

When you are trying to access the api without token :
image

For login : (http://localhost:8080/auth/login) : This api is permitted without the valid jwt token .
After hitting this api with valid payload , a JWT token will been generated with which you can access other protected api's.

image

After login :
When you are hitting any protected api you need to pass the generated jwt token with the api
Key : Authorization
value : Bearer + blank space + generated jwt token

image

In the below image you can see the difference when you pass a invalid jwt token and a valid jwt token.
When you pass a invalid jwt token you will get a message in the console as Invalid Header Value .

image
image

About

This repository is related to spring boot security with JWT (JSON WEB TOKEN) .

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages