Skip to content

ezeparziale/flask-auth-google-template

Repository files navigation

🔑 Flask auth google template

Flask app with Google auth login and postgres db

💾 Installation

python -m venv env
. env/scripts/activate
pip install --upgrade pip
pip install -r requirements.txt

🔧 Config

Create .env and .env.db files. Check the examples .env.example and .env.db.example

🌐 Google Auth credentials:

Create your app and obtain your client_id and secret:

https://developers.google.com/workspace/guides/create-credentials

🚧 Before first run:

Run docker-compose 🐳 to start the database server

docker compose -f "docker-compose.yml" up -d --build adminer db

and init the database with alembic:

alembic upgrade head

🔑 How to create cert and key

For run the option 2 or option 3 you need a cert.pem and key.pem.

Create a self-signed certificate with openssl:

openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365

🏃 Run

🥇 Option 1

Run the database with docker and the app with flask using a cert adhoc.

  • Database:
docker compose -f "compose.yaml" up -d --build adminer db
  • Flask app:
flask --debug run --cert=adhoc

🥈 Option 2

Run the database with docker and the app with flask using your certificate.

  • Database:
docker compose -f "compose.yaml" up -d --build adminer db
  • Flask app:
flask --debug run --cert=cert.pem --key=key.pem

🥉 Option 3

Run the database and the flask app with docker. This option use a cert and key.
In this option Flask run over gunicorn.

  • Database and flask app:
docker compose -f "compose.yaml" up -d --build

📌 Features

  • Google Auth login
  • Sign up new users
  • Bootstrap
  • Flask
  • Alembic
  • Docker
  • Docker compose