6989a98d75
- Arkitektur: docs/auth/passwordless-architecture.md - Backend: iom/quixzoom-auth-service/ (FastAPI + Redis) - Webb: quixzoom-market-pages/se/login/ (QR-kod + polling) - App: iom/quixzoom-app/src/features/auth/ (push + deep links) Flöde: QR-kod → app-godkännande → webb-inloggad
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
"""
|
|
quiXzoom Passwordless Authentication Service
|
|
Cross-device login between app and web
|
|
"""
|
|
|
|
import os
|
|
from fastapi import FastAPI, Request
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
import uvicorn
|
|
|
|
from routes.passwordless import router as passwordless_router
|
|
|
|
app = FastAPI(
|
|
title="quiXzoom Passwordless Auth",
|
|
description="Passwordless cross-device authentication service",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[
|
|
"https://quixzoom.se",
|
|
"https://www.quixzoom.se",
|
|
"https://quixzoom.com",
|
|
"https://www.quixzoom.com",
|
|
"http://localhost:3000",
|
|
"http://localhost:8080",
|
|
],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Error handler
|
|
@app.exception_handler(Exception)
|
|
async def global_exception_handler(request: Request, exc: Exception):
|
|
return JSONResponse(
|
|
status_code=500,
|
|
content={"error": "Internal server error", "detail": str(exc)}
|
|
)
|
|
|
|
# Health check
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "ok", "service": "passwordless-auth"}
|
|
|
|
# Include routes
|
|
app.include_router(passwordless_router, prefix="/v1")
|
|
|
|
if __name__ == "__main__":
|
|
port = int(os.getenv('PORT', 8080))
|
|
host = os.getenv('HOST', '0.0.0.0')
|
|
uvicorn.run(app, host=host, port=port)
|