This is a template project for a VueJS frontend with a Spring Boot backend. The backend is secured with Spring Security and OAuth2. The frontend is secured with JWT. The backend uses PostgreSQL as a database.
- Java 21
- VueJS (Quasar)
- Spring Boot 3.3.5
- Spring Security 6.3.4
- PostgreSQL
- Liquibase
- Docker
- Go to the Docker Desktop website.
- Download and install Docker Desktop.
- Run Docker Desktop.
- Run docker-compose to start a PostgreSQL database (database will be available by URL
jdbc:postgresql://localhost:5433/postgres
, usernamepostgres
, passwordexample
):
docker-compose up -d
- Copy the username and password and add them to environment variables
POSTGRES_USER
andPOSTGRES_PASSWORD
. Theapplication.yaml
file is already configured to read these environment variables.
- Set any JWT key to the environment variable JWT_SECRET. The
application.yaml
file is already configured to read this environment variable.
- Go to the Google Cloud Console.
- Create a new project.
- Go to the
APIs & Services
->Credentials
section. - Create a new OAuth Client ID.
- Add
http://localhost:your_frontend_port/login
as Authorized JavaScript origins. Keep in mind theyour_frontend_port
must be the same as the frontend port that defined in thequasar.conf.js
file, which is9000
by default. - Add
http://localhost:your_backend_port/api/v1/login/oauth2/code/google
Authorized redirect URIs. Here portyour_backend_port
is the backend port that defined in theapplication.yaml
file, which is9090
by default. - Copy the
Client ID
andClient Secret
and add them to environment variables GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET. Theapplication.yaml
file is already configured to read these environment variables.
Run the following command in the root directory of the project:
maven clean install
Run the following command in the root directory of the project:
cd src/main/vue
npm install
Run the following command in the root directory of the project:
java -jar target/auth-0.0.1-SNAPSHOT.jar
Run the following command in the root directory of the project:
cd src/main/vue
quasar dev
- Open the frontend in your browser:
http://localhost:9000/login
. - Click on the
Login with Google
button. - You will be redirected to the Google login page.
- After successful login, you will be redirected back to the frontend.
- Open the frontend in your browser:
http://localhost:9000/register
. - Fill in the form and click on the
Register
button. - You will be redirected to the login page.
- Login with the credentials you just registered.