Skip to content

ablogo/AuthFastApi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AuthFastApi

Authentication microservice, the goal of this project is to learn Python and FastApi, it will be updated as new versions of these tools are released.

It is a microservice for user administration and authenication, using JWT tokens and encrypting the information within it, different approaches are used, that is why there may be different implementations performing the same functions.

Requirements

  • Python 3.12+
  • FastApi 0.124+

Important

It is necessary to complete the configuration file(.env), and create the PEM files and place them in the root folder

Installing

  1. Create a virtual environment
python -m venv .venv
  1. Activate it (Linux, macOS)
source .venv/bin/activate

Activate it (Windows PowerShell)

.venv\Scripts\Activate.ps1
  1. Install dependencies
pip install -r requirements.txt
  1. Generate the RSA keys files and name them as 'private_key.pem' and 'public_key.pem', and place them in the project's root folder
openssl genrsa -out private_key.pem 2048
chmod 0400 private.pem

Use the private key file to extract the public key in PEM format

openssl rsa -in private_key.pem -pubout -out public_key.pem
  1. Set configuration file (.env)

The microservice uses mongoDB as its database, so the connection string and other configurations (mongodb, JWT, CORS, logs) must be included

  1. Run local development server
uvicorn src.main:app --reload
  1. Open the next url in a browser to see the Swagger UI
http://127.0.0.1:8000/docs

Using with Docker

  1. Create the image
docker build -t auth-service:latest .

Or download the image hosted in this repository.

docker pull ghcr.io/ablogo/authfastapi:latest
  1. Run a container from the image previously created
docker run -p 8000:80 --env-file .env auth-service:latest

Note

Since the project is used for learning, it does not strictly follow the concept of microservices, where each microservice should have its own realm of responsability

About

Authentication microservice

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages