Skip to content
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

Django 3.0 Async Support #223

Closed
Andrew-Chen-Wang opened this issue Mar 9, 2020 · 3 comments
Closed

Django 3.0 Async Support #223

Andrew-Chen-Wang opened this issue Mar 9, 2020 · 3 comments

Comments

@Andrew-Chen-Wang
Copy link
Member

Andrew-Chen-Wang commented Mar 9, 2020

I’m in need of utilizing Django 3.0’s asgi.py with authentication methodology. There already is an issue #71 raised for httpCookie storage, so web is covered, I suppose, since Django 3.0 can’t access the database being not thread safe.

When it comes to 3.0 support, the token blacklist and sliding token will not be available until Django 3.0 make db access thread safe. Plus, creating too many threads is going to kill any EC2 instance...

HOWEVER, when it comes to regular authentication, we should add a method for people to utilize. Or a function. My setup for asgi.py is as follows: https://dev.to/jaydenwindle/adding-websockets-to-your-django-app-with-no-extra-dependencies-2f6h

The authentication method should be a function that returns a Bool. OR, with the above link’s asgi.py setup, we could also automatically send a status code.

I’m suggesting this since simplejwt mainly serves mobile authentication rather than desktop as the aforementioned issue is developed for.

@Andrew-Chen-Wang
Copy link
Member Author

If you take a look at Django 3.0 development in Google Group, you'll find out that the creator of psycopg2 might be creating a native async psycopg3! So if you use Django 3.0 + psycopg3, it might not be necessary to change too much code. But for now, is anyone looking into creating this (besides me)?

@Andrew-Chen-Wang
Copy link
Member Author

For those later on: I created a native Django 3.0 chat application (i.e. without django channels). In order to connect to a certain pool, the user first needs to perform a POST request to a view. The view returns a token. That view also adds the token to redis (or whatever your cache may be). The token is the key and the value is whatever you want it to be. When you connect via web sockets to a pool, the websocket.connect protocol will access the cache and look for the cache.

Doing this with this package would not be good because simplejwt is not THAT customizable of an app. However, I can make it happen. But keeping up with celery and other things...

@Andrew-Chen-Wang
Copy link
Member Author

Written in a gist (needs some more revision, but already deployed in an app using Redis pub/sub with SimpleJWT methodology for getting a custom TokenUser).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant