You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are no similar issues or pull requests for this yet.
Is your feature related to a problem? Please describe.
Hi, was working on a task and ran into an issue where my application initializes two sessions.
AuthenticationBackend class creates its own session in the init method:
classAuthenticationBackend:
"""Base class for implementing the Authentication into SQLAdmin. You need to inherit this class and override the methods: `login`, `logout` and `authenticate`. """def__init__(self, secret_key: str) ->None:
fromstarlette.middleware.sessionsimportSessionMiddlewareself.middlewares= [
Middleware(SessionMiddleware, secret_key=secret_key),
]
But if I need a session also in my application I initialize, when starting the app
I think you can subclass AuthenticationBackend to modify this.
But adding middlewares to the init is also fine by me. We just have to make it optional and initialize it when no argument is passed.
Checklist
Is your feature related to a problem? Please describe.
Hi, was working on a task and ran into an issue where my application initializes two sessions.
AuthenticationBackend class creates its own session in the init method:
But if I need a session also in my application I initialize, when starting the app
and then I can't use session object from AuthBackend
Describe the solution you would like.
I think it would be more transparent to pass this middleware to the AuthenticationBackend, for example like this:
and initialize this middleware on application startup:
I hope this helps someone spend less time looking for the problem than it took me to find it 🥲
The text was updated successfully, but these errors were encountered: