Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion flask_user/token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import base64
import string
import sys

# Non-system imports are moved into the methods to make them an optional requirement

Expand Down Expand Up @@ -43,7 +44,10 @@ def __init__(self, app):
raise ConfigError('Config setting SECRET_KEY is missing.')

# Print a warning if SECRET_KEY is too short
key = flask_secret_key.encode()
if sys.version_info[0] < 3:
key = flask_secret_key.encode()
else:
key = flask_secret_key
if len(key)<32:
print('WARNING: Flask-User TokenManager: SECRET_KEY is shorter than 32 bytes.')
key = key + b' '*32 # Make sure the key is at least 32 bytes long
Expand Down