S
S
Sergey Pashkevich2015-11-23 20:52:30
Django
Sergey Pashkevich, 2015-11-23 20:52:30

How to implement Django + Tornado interaction?

Hello everyone,
there was a problem with the interaction of django + tornado, namely the project is written in django (api (django-rest-framework)), frontend (react), user authentication through jwt tokens, and now you need to fasten private messages, chat (real- time). Initially I wanted to bring it to node.js, but after googling I came across a non-blocking server and a framework (tornado) and even in python, the choice fell on it, but now the problem is how do I authenticate a user in a chat (tornado) if I don’t have sessions, but there are only tokens, so that it would be possible to implement a message exchange between users?
So far I'm doing this:
1) I connected the library for working with jwt tokens to tornado
2) when setting up a socket connection, I passed the user's token in the parameter
3) decrypted this token on the back using the same private key that was used for encryption, and received the user id
4) using the Psycopg2 driver directly accessed the database to write and read data from tables
Maybe someone will advise something better than this solution ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2015-11-23
@sim3x

habrahabr.ru/post/160123
ADF: if you don't like putting it in a radish, don't put it. Until a certain RPS, postgres is enough for you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question