Closed jet10000 closed 4 years ago
I use it with fastapi this way:
async def maybe_user(session=Depends(get_session)):
return await auth_backend.get_user_from_session(session).load()
async def active_user(user: User = Depends(maybe_user)):
if not user:
raise HTTPException(401)
if not user["is_active"]:
raise HTTPException(403, "User isn't active")
return user
async def staff_user(user: User = Depends(active_user)):
if not user["is_staff"] and not user["is_superuser"]:
raise HTTPException(403, "Staff user required")
return user
I'll commit it a bit later if there won't be any pitfalls. Where would you add aiosmtpd?
A system built on django and postgreSQL, including web, mobile app, chat, and mailserver, accepts email and sends email through a web interface (equivalent to a simplified mail system, receive email checked by django's authentication system).
web -> django or starlette mobile app -> fastapi chat -> aiohttp websokcet mailserver -> aiosmtpd (similar to haraka, but combined with django user module and just receive email and send email)
:)
https://github.com/tiangolo/fastapi
and possible to add aiosmtpd_app.py?
https://github.com/aio-libs/aiosmtpd
:)