Skip to content

An example for showing how can we use JWT with spring boot for security.

License

Notifications You must be signed in to change notification settings

nailcankucuk/spring-security-jwt-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Security JWT Api

This is an example app for Spring Boot Security via JSON Web Token.

There are 3 REST methods in this app.

  • for signup a new user
  • for signin with username and password
  • for get a user's details with user id

For access to signup and signin methods you don't need to a token but for get user's details method you need it. When you signin with a user, app gives you a JSON Web Token and you can access the user details method with it.

How can you run the application

You should firstly change the DB connection configurations in build.gradle and application.yml files before run code. I use MySQL DB for test it. You may need to do some changes in configuration and SQL files if you want to use another DB.

Run this codes for create jar file:

$ ./gradlew clean build

and start the application:

$ java -jar build/libs/spring-security-jwt-api-0.0.1-SNAPSHOT.jar

How can you test it

I use Postman for test my app.

Firstly you need to create a new user and you can do it with postman like this:

signup

then signin with new user like this:

signin

Now you have got a new token 🤘 For access the other REST methods you should use this token and send it too in request header. This 2 images are for accessible and non-accessible cases:

access

not_access

About

An example for showing how can we use JWT with spring boot for security.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages