-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea: Allow session usage without Token model #161
Comments
I can see session support being helpful for people who are building hybrid SPA apps in Django - where Django serves an html template and that template includes some React/Vue. However this package is not built with that use case in mind. This package is focused on stateless and decoupled client/server architectures based on REST. Using sessions would violate lots of architectural principles that underpin that. |
So I have the exact opposite problem :-D |
Yes @io-ma setting REST_SESSION_LOGIN = False, wont perform django's default session login and logout. I know its bit late to reply but maybe helpful for others having same question. |
I also need the option to use the session-based authentication without generating a token.
Could you give some examples of situation the session is undesirable? @iMerica |
What's wrong with that use case? I would think it's quite common to want to use the Django admin site out of the box, but also enable session login with dj-rest-auth for a frontend built with a javascript framework. For any app that runs in a web browser, a login cookie works fine and is exactly as stateful or stateless as using |
The
|
This is in the latest release |
Use case
Sometimes it's desirable to have a SPA that only uses session authentication. Sessions are very simple and work sufficiently well when the SPA is running all under one domain.
Problem
It's not obvious how to do this. The quickstart suggests enabling
rest_framework.authtoken
. There is a setting to use JWT authentication instead. But there is no obvious way to use sessions and only session.Workaround
We can fake auth tokens with "no op" functions and classes.
An alternative workaround is to enable auth token even though it isn't used. This can lead to problems such as this which are not obvious how to around. Custom logic around user models and login views must account for unnecessary token creation.
In either case, the workaround involves either going out of ones way to support tokens, which are then never used, or ensuring they get disabled at all times.
The text was updated successfully, but these errors were encountered: