mirror of
https://github.com/django/daphne.git
synced 2025-07-08 13:53:18 +03:00
Merge pull request #31 from ekmartin/string_session
Store the session key as a string
This commit is contained in:
commit
612b37f184
|
@ -50,8 +50,9 @@ def channel_session(func):
|
||||||
# Turn the reply_channel into a valid session key length thing.
|
# Turn the reply_channel into a valid session key length thing.
|
||||||
# We take the last 24 bytes verbatim, as these are the random section,
|
# We take the last 24 bytes verbatim, as these are the random section,
|
||||||
# and then hash the remaining ones onto the start, and add a prefix
|
# and then hash the remaining ones onto the start, and add a prefix
|
||||||
reply_name = str(message.reply_channel.name).encode()
|
reply_name = message.reply_channel.name
|
||||||
session_key = b"skt" + str(hashlib.md5(reply_name[:-24]).hexdigest()[:8]).encode() + reply_name[-24:]
|
hashed = hashlib.md5(reply_name[:-24].encode()).hexdigest()[:8]
|
||||||
|
session_key = "skt" + hashed + reply_name[-24:]
|
||||||
# Make a session storage
|
# Make a session storage
|
||||||
session_engine = import_module(settings.SESSION_ENGINE)
|
session_engine = import_module(settings.SESSION_ENGINE)
|
||||||
session = session_engine.SessionStore(session_key=session_key)
|
session = session_engine.SessionStore(session_key=session_key)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user