Improved
FastAPI Session Type Safety
15 days ago by Jim Verducci
📣 FastAPI Auth SDK 1.1.0 Release 🎉
Please refer to the GitHub README for updated documentation and details.
Session Access and Type Safety Improvements
Enhanced session management with better type safety and dual access patterns:
Key Changes
- Added
get_session()dependency function: Provides typedSessionaccess without performing auth/CSRF validation, useful for router-level protected routes or non-protected access - Session Protocol as public interface: Promoted
SessionProtocol to public API for type-safe session access with IDE autocomplete. Support for extendingSessionProtocol with custom typed fields. - Dual session access patterns: Sessions now accessible via both
request.state.session(untyped) and typedSessiondependency injection viaDepends(get_session)orDepends(require_session_auth) - README updated throughout to reflect all changes
- The FastAPI Demo App has been updated to to use these SDK changes.