This is a FastAPI-based authentication system that implements passwordless authentication using magic links.
- Request magic link authentication
- Verify magic link tokens
- Email-based authentication
- JWT token generation and verification
- Docker support for easy deployment
-
Configure environment variables:
cp .env.example .env
Update the following variables in
.env:SECRET_KEY: Your secret key for JWT tokensSMTP_USER: Your email addressSMTP_PASSWORD: Your email app passwordSMTP_HOST: SMTP server addressSMTP_PORT: SMTP server port
-
Build and run with Docker Compose:
docker-compose up --build
The API will be available at http://localhost:8000
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables as described above
-
Run the application:
uvicorn main:app --reload
- POST
/request-magic-link: Request a magic link (requires email in request body) - GET
/verify: Verify magic link token (requires token query parameter)
- Send a POST request to
/request-magic-linkwith an email:
{
"email": "user@example.com"
}- Check email for magic link
- Click the magic link or use the token in the
/verifyendpoint
- In production, update CORS settings to allow only specific origins
- Use strong SECRET_KEY
- Store sensitive information in environment variables
- Configure proper email settings