FastAPI-Login tries to provide similar functionality as Flask-Login does.
FastAPI-Login brings user authentication capabilities to FastAPI applications, mirroring the functionality that Flask-Login offers for Flask applications. This library is designed to simplify the process of managing user sessions and securing routes with JSON Web Tokens (JWT), making it a great choice for developers looking to implement authentication in their FastAPI projects efficiently.
FastAPI-Login is easy to integrate into your application, supported by comprehensive documentation that guides you through installation, setup, and usage. By leveraging this authentication library, developers can handle user logins, token creation, and session management directly within the FastAPI ecosystem.
JWT Management: FastAPI-Login manages the encoding and decoding of JSON Web Tokens with ease, supporting secure user authentication.
User Loader: A customizable user loader callback allows you to define how user data is retrieved from your database, providing flexibility in user management.
Expiration Control: Control the token expiration with the expires_delta argument, allowing you to set appropriate session durations for your application's security needs.
Cookie Support: In addition to token headers, FastAPI-Login supports authentication through cookies, providing an alternative method for accessing secured routes.
Convenient Set-Cookie Method: The library includes a set_cookie method, which simplifies cookie management by automatically setting cookies with the recommended HTTPOnly flag.
Error Handling: FastAPI-Login allows for custom error handling by enabling developers to define their own subclass of Exception for unauthenticated access attempts.
Easy Integration: Plug the LoginManager into your FastAPI routes seamlessly, allowing for straightforward dependency injection and management of user sessions throughout your application.