Skip to content

SeaRoll/spring-boot-architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Architecture

A very simple example of a Spring Boot application that uses a layered architecture, JWT generation & authentication per SCOPE, automatic local development & testing setup with testcontainers.

Things you will need

  • Java 21
  • IntelliJ IDEA

General info

  • Written using spring boot
  • Uses postgreSQL as database
  • Uses lombok which needs to be enabled/configured in your editor
  • Database migrations done with flyway
  • Tests done in JUnit 5 with Testcontainers
  • Uses Spring Security with JWT tokens for authentication & authorization
  • Maven wrapper is included for building/testing
    • On Unix systems use: ./mvnw clean verify
    • On Windows: ./mvnw.cmd clean verify

Pull requests requirements

  • run ./mvnw fmt:format before pushing
  • run ./mvnw clean verify before pushing

Running the application locally

Navigate to the root of test folder, And then run the LocalDevApplication class. This will start all necessary docker containers and run the application locally.

Example of security:

curl -s --location "http://localhost:8080/auth/token" \
> --header "Content-Type: application/json" \
> --data "{
>     \"sub\": \"123\",
>     \"scope\": [
>         \"role1\",
>         \"role2\",
>         \"GUEST\"
>     ]
> }"

eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAiLCJzdWIiOiJkbWl0cnkiLCJleHAiOjE3MDM5NTg4MjcsImlhdCI6MTcwMzk1ODIyNywic2NvcGUiOlsicm9sZTEiLCJyb2xlMiIsIkdVRVNUIl19.sgwvUVJazeEdhM1Vy8eXGjvGIXkAYWFfRg_VaNpISdU
curl -s --location "http://localhost:8080/greeting" \
--header "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwODAiLCJzdWIiOiJkbWl0cnkiLCJleHAiOjE3MDM5NTg4MjcsImlhdCI6MTcwMzk1ODIyNywic2NvcGUiOlsicm9sZTEiLCJyb2xlMiIsIkdVRVNUIl19.sgwvUVJazeEdhM1Vy8eXGjvGIXkAYWFfRg_VaNpISdU"

Hello, 123. You have next permissions: [SCOPE_role1, SCOPE_role2, SCOPE_GUEST]

About

Custom barebones spring boot architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published