MultiAuth is a multi-tenant authentication system that supports both email/password authentication and Google OAuth. It allows different organizations (tenants) to have isolated authentication while enabling admin functionalities for user management.
- User Authentication (Signup/Login with Email & Password)
- Google OAuth Authentication
- Multi-Tenant Support (Users belong to different organizations)
- Admin Functionality (Admins can see users in their tenant and promote them)
- Session Handling with JWT Tokens
- Frontend in React (Vite) and Backend in Flask
- Frontend: React (Vite), TypeScript, Axios, TailwindCSS
- Backend: Flask, Flask-JWT-Extended, Flask-CORS, Flask-Session
- Database: SQLite (for local development), PostgreSQL (for production)
- Authentication: JWT for API protection, Google OAuth for third-party login
git clone https://github.com/your-repo/MultiAuth.git
cd MultiAuth
cd backend
python -m venv venv # Create virtual environment
source venv/bin/activate # Activate virtual environment (Mac/Linux)
venv\Scripts\activate # Activate virtual environment (Windows)
pip install -r requirements.txt
Create a .env
file inside backend/
and add:
SECRET_KEY=your-secret-key
SQLALCHEMY_DATABASE_URI=sqlite:///multiauth.db
JWT_SECRET_KEY=your-jwt-secret-key
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
flask db upgrade # Apply migrations
flask run # Start Backend (Runs on http://127.0.0.1:5000)
cd ../frontend
npm install # Install dependencies
npm run dev # Runs on http://127.0.0.1:5173
Inside frontend/src/api/auth.ts
, update the backend API URL:
const API_URL = "http://127.0.0.1:5000/api";
- Sign up with a tenant name (first user in a tenant is admin)
- Log in using Email/Password or Google OAuth
- Admins can see users in their tenant (
/api/users
) - Admins can promote users to admins (
/api/promote
) - Logout & Session Handling
- Ensure the
.env
file is properly set up. - Run
flask db upgrade
to apply migrations. - Restart the virtual environment:
deactivate && source venv/bin/activate # Mac/Linux deactivate && venv\Scripts\activate # Windows
- Ensure backend is running on
http://127.0.0.1:5000
. - Check if the API URL in
vite.config.ts
is correct.
- Ensure Google Client ID and Secret are set in
.env
. - Check OAuth Redirect URI in Google Developer Console.