/spring-boot-jwt-boilerplate

SpringBoot Boilerplate with JWT Refresh Token

Primary LanguageJava

Spring Boot JWT Boilerplate

SpringBoot Boilerplate with JWT Refresh Token

🔧 How to use?

🔎 Requirements:

  • Docker and docker-compose.
  • Java 11 or higher.

👟 Steps:

  1. Clone this repository to your machine and open the terminal already in the project directory.
  2. Use the command docker-compose up -d, to start the MySQL.
  3. Use the command ./mvnw clean package to generate the .jar.
  4. Use the command ./mvnw spring-boot:run to start the server.

Everything must be working properly.

⚙️ Default Config

By default, an admin user will be created when the users table is empty with this data:

{
  "email": "admin@mail.com",
  "password": "admin123",
  "username": "Admin"
}

To change this default information you can add the values in your properties file(application.properties, application.yml), for example:

app:
  init:
    user:
      email: testemail@mail.com
      password: somepass
      username: testname

For better security, it is also recommended that you change the properties for JWT creation.

app:
  jwt:
    secret: YOUR_SECRET_KEY
    expirationMs: 3600000 # 1 hour
    refreshExpirationMs: 2592000000 # 30 days

🌐 Authentication Flow

JWT Authentication Flow

🚀 Technologies

❤️ Thanks