- Once the JWT has expired, the user/system will make a call to another url suppose /refreshtoken. Also along with this request the expired JWT should be passed. The Server will then return a new JWT which can be used by the user/system
- Here is the explanation of the project
- Implement the process of registering for user by default of its defined role
- Implement the process of signing in the system for user
- Implement the process of refreshing token when JWT has expired
- Implement the process of opening page with respect to user's defined role
- Implement the process of signing out from the system for user
1 ) Download your project from this link https://github.com/Rapter1990/SpringBootRefreshTokenJWT
2 ) Go to the project's home directory : cd SpringBootRefreshTokenJWT
3 ) Create a jar file though this command mvn clean install
4 ) Run the project though this command mvn spring-boot:run
5 ) Explore Rest APIs
Method | Url | Description | Valid Request Body | Valid Header |
---|---|---|---|---|
POST | /signup | Sign Up | Info | |
POST | /signin | Sign In | Info | |
POST | /logout | Logout | Info | |
POST | /refreshtoken | Refresh Token | Info | |
GET | /pages/all | Show Public Content | Info | |
GET | /pages/user | Show User Content | Info | |
GET | /pages/admin | Show Admin Content | Info | |
GET | /pages/moderator | Show Moderator Content | Info |
- Spring Boot Web
- Spring Security
- Spring Boot Test
- Spring Boot Starter Validation
- JSON Web Token
- Google Code JSON
- Lombok
- Mysql
- Swagger
{
"username" : "User1",
"password" : "user1",
"email" : "user@refreshtoken.com"
}
{
"username" : "User1",
"password" : "user1",
"email" : "user1_role_user@refreshtoken.com",
"roles" : [
"ROLE_USER"
]
}
{
"username" : "User1",
"password" : "user1",
"email" : "user1_role_user@refreshtoken.com",
"roles" : [
"ROLE_USER", "ROLE_MODERATOR"
]
}
{
"username" : "User1",
"password" : "user1"
}
{
"refreshToken" : "a93444ea-5c0f-4130-8f80-0cce82d53155"
}
http://localhost:1221/api/auth/logout
Authorization : Bearer {accessToken}
http://localhost:1221/api/pages/all
http://localhost:1221/api/pages/user
Authorization : Bearer {accessToken}
http://localhost:1221/api/pages/admin
Authorization : Bearer {accessToken}
http://localhost:1221/api/pages/moderator
Authorization : Bearer {accessToken}