Files
boc/iom/quixzoom-auth-service/main.py
T

56 lines
1.4 KiB
Python
Raw Normal View History

"""
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)