AuthTuna – A modern, async security framework for FastAPI

3 pointsposted 6 hours ago
by shashstormer

Item id: 45249930

2 Comments

scottydelta

5 hours ago

So FastAPI is a web framework and AuthTuna is a framework for a framework?

Does FastAPI has a mechanism to add external modules? Like Django calls it an app. People can make open-source Django apps and others can easily include them in their own Django project base.

Good job on launching!

shashstormer

5 hours ago

Hey scottydelta, thanks for the kind words and the great questions!

That's a great way to put it, and you're right that "framework for a framework" can sound a bit heavy! I think of AuthTuna more as a batteries-included library or an extension for FastAPI. You could compare it to a powerful, reusable Django 'app' that handles all things security-related.

You've hit on a key difference between Django and FastAPI's ecosystems. FastAPI doesn't have a central INSTALLED_APPS setting like Django. Instead, it encourages a more explicit, composable approach using a few key features:

Routers (APIRouter): This is the closest equivalent. A library like AuthTuna can provide a router with all its endpoints (e.g., /login, /logout), and you can mount it in your main app with a single line: app.include_router(auth_router). This is how you "plug in" a set of views.

Middleware: For things that need to run on every request, like our session management, you add it as middleware: app.add_middleware(...).

Dependencies: For protecting specific endpoints, you use FastAPI's powerful dependency injection system: user: User = Depends(get_current_user).

So while it's not a single "app" concept, the combination of these three features allows for creating powerful, reusable components like AuthTuna that can be easily integrated into any FastAPI project.