Development of two authentication projects in microservices, using two models: stateful and stateless. Auth represents an authentication API. Any represents any API, which will only have to validate the access token. The operating model of the applications will be shown below.
This table highlights the key differences between stateless and stateful systems:
Stateless | Stateful |
---|---|
No session | Session-based |
No login | Login functionality |
No basket | Basket functionality |
Static content | Dynamic content |
Stateless systems are typically simpler and scale better, but stateful systems are more suitable for interactive and personalized applications.
git clone https://github.com/RamonBecker/ms-auth.git
git clone https://github.com/RamonBecker/ms-auth.git
or install github https://desktop.github.com/
Before cloning the project, you will need to install docker on your operating system.
For windows, enter the following from the link:
https://docs.docker.com/desktop/windows/install/
For linux, follow the procedure below:
- Update your existing list of packages:
sudo apt update
- Install some prerequisite packages that let apt use packages over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- Add the GPG key to the official Docker repository on your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Add the Docker repository to the APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
- Update the package database with Docker packages from the newly added repository:
sudo apt update
- Make sure you are about to install from the Docker repository instead of the default Ubuntu repository:
apt-cache policy docker-ce
- Install Docker:
sudo apt install docker-ce
- Check if it is working:
sudo systemctl status docker
After cloning the project, perform the following Enter the services folder, then enter the v2 folder and run the following command:
docker-compose up
-
Download the Python Installer
- Visit the official Python website: https://www.python.org/downloads/.
- Click the button to download the latest version of Python 3 for Windows.
-
Run the Installer
- Locate the downloaded file and double-click to open it.
- Important: Check the "Add Python 3.x to PATH" option before clicking "Install Now."
-
Choose the Installation Type
- Recommended: Click "Install Now" for a default installation.
- To customize, click "Customize Installation."
-
Complete the Installation
- Once the installation finishes, click "Close."
-
Verify the Installation
- Open the Command Prompt and type:
or
python --version
python3 --version
- This will display the installed Python version.
- Open the Command Prompt and type:
-
Update Repositories
- Open the terminal and run:
sudo apt update && sudo apt upgrade -y
- Open the terminal and run:
-
Install Python 3
- For Debian/Ubuntu-based distributions:
sudo apt install python3
- For Fedora/CentOS-based distributions:
sudo dnf install python3
- For Debian/Ubuntu-based distributions:
-
Install Pip
- On Debian/Ubuntu:
sudo apt install python3-pip
- On Fedora/CentOS:
sudo dnf install python3-pip
- On Debian/Ubuntu:
-
Verify the Installation
- In the terminal, type:
python3 --version
- This will display the installed Python version.
- In the terminal, type:
- Virtual Environments:
To manage dependencies in isolation, create a virtual environment:
python3 -m venv env_name source env_name/bin/activate # Linux/Mac env_name\Scripts\activate # Windows
Below are the host and port details for the APIs:
Application | URL |
---|---|
stateless-auth-api |
http://localhost:8080/swagger-ui/index.html |
stateless-any-api |
http://localhost:8081/swagger-ui/index.html |
stateful-auth-api |
http://localhost:8082/swagger-ui/index.html |
stateful-any-api |
http://localhost:8083/swagger-ui/index.html |
Below are the host and port details for the databases:
Database | Type | Host | Port |
---|---|---|---|
stateless-auth-db |
PostgreSQL | localhost |
5432 |
stateful-auth-db |
PostgreSQL | localhost |
5433 |
token-redis |
Redis | localhost |
6379 |
To run all applications and databases using the utility script, execute the following command:
python3 build.py
Here are some useful Docker commands to manage containers and logs:
- Stop all containers:
docker stop $(docker ps -aq)
- Remove all containers:
docker container prune -f
- Follow logs for the
token-redis
container:docker logs --follow token-redis
- Execute a shell command to connect to Redis:
docker exec -it token-redis redis-cli
- Go to the official DBeaver download page: DBeaver Download.
- Select the Windows version (typically Windows 64-bit).
- The installer will be downloaded as an
.exe
file.
- Locate the downloaded
.exe
file and double-click to run the installer. - The DBeaver Setup Wizard will appear. Follow the on-screen instructions:
- Choose the installation directory or leave the default.
- Select additional options, such as whether to create shortcuts on the Start Menu and Desktop.
- Once the installation is complete, click Finish.
- DBeaver will launch automatically, or you can open it from the Start Menu or Desktop.
- Upon first launch, you will be prompted to configure some initial preferences:
- Select your preferred UI theme (light or dark).
- Choose any additional plugins or settings you want to configure.
- After setting up, you can start connecting to your databases.
There are installation methods for both Debian-based distributions (such as Ubuntu) and RPM-based distributions (such as Fedora). Additionally, you can install DBeaver via Snap or Flatpak.
-
Download the .deb Package
- Visit the official DBeaver download page: DBeaver Download.
- Choose the Debian (64-bit) version for your system.
-
Install the .deb Package
- Open a terminal and navigate to the folder where the
.deb
file was downloaded. - Run the following command to install DBeaver:
sudo dpkg -i dbeaver-ce_<version>.deb
- If there are any missing dependencies, run:
sudo apt-get install -f
- Open a terminal and navigate to the folder where the
-
Run DBeaver
- Once the installation is complete, you can launch DBeaver from the application menu or run it from the terminal:
dbeaver
- Once the installation is complete, you can launch DBeaver from the application menu or run it from the terminal:
-
Download the .rpm Package
- Visit the official DBeaver download page: DBeaver Download.
- Choose the RPM (64-bit) version for your system.
-
Install the .rpm Package
- Open a terminal and navigate to the folder where the
.rpm
file was downloaded. - Run the following command to install DBeaver:
sudo rpm -i dbeaver-ce-<version>.rpm
- Open a terminal and navigate to the folder where the
-
Run DBeaver
- After installation, you can run DBeaver from the application menu or execute it via the terminal:
dbeaver
- After installation, you can run DBeaver from the application menu or execute it via the terminal:
You can also install DBeaver using Snap or Flatpak on Linux.
- Open a terminal and run:
sudo snap install dbeaver-ce
- Java
- Spring Boot
- API REST
- PostgreSQL (Container)
- Docker
- Docker-compose
- JWT
- Token
- Login Validation
- Logout Validation
- Token Validation
By Ramon Becker ππ½ Get in touch!