|
13 | 13 |
|
14 | 14 |
|
15 | 15 | SNEAKY_USER_AGENTS = ('Slackbot', 'facebookexternalhit', 'Twitterbot',
|
16 |
| - 'Facebot', 'WhatsApp', 'SkypeUriPreview', |
17 |
| - 'Iframely') |
| 16 | + 'Facebot', 'WhatsApp', 'SkypeUriPreview', 'Iframely') |
18 | 17 | SNEAKY_USER_AGENTS_RE = re.compile('|'.join(SNEAKY_USER_AGENTS))
|
19 | 18 | NO_SSL = os.environ.get('NO_SSL', False)
|
20 | 19 | TOKEN_SEPARATOR = '~'
|
21 | 20 |
|
22 | 21 |
|
| 22 | +# Initialize Flask Application |
23 | 23 | app = Flask(__name__)
|
24 | 24 | if os.environ.get('DEBUG'):
|
25 | 25 | app.debug = True
|
26 | 26 | app.secret_key = os.environ.get('SECRET_KEY', 'Secret Key')
|
27 | 27 | app.config.update(
|
28 | 28 | dict(STATIC_URL=os.environ.get('STATIC_URL', 'static')))
|
29 | 29 |
|
| 30 | +# Initialize Redis |
30 | 31 | if os.environ.get('MOCK_REDIS'):
|
31 | 32 | from mockredis import mock_strict_redis_client
|
32 | 33 | redis_client = mock_strict_redis_client()
|
|
38 | 39 | redis_db = os.environ.get('SNAPPASS_REDIS_DB', 0)
|
39 | 40 | redis_client = redis.StrictRedis(
|
40 | 41 | host=redis_host, port=redis_port, db=redis_db)
|
| 42 | +REDIS_PREFIX = os.environ.get('REDIS_PREFIX', 'snappass') |
41 | 43 |
|
42 | 44 | TIME_CONVERSION = {'week': 604800, 'day': 86400, 'hour': 3600}
|
43 | 45 |
|
@@ -97,7 +99,7 @@ def set_password(password, ttl):
|
97 | 99 | Returns a token comprised of the key where the encrypted password
|
98 | 100 | is stored, and the decryption key.
|
99 | 101 | """
|
100 |
| - storage_key = uuid.uuid4().hex |
| 102 | + storage_key = REDIS_PREFIX + uuid.uuid4().hex |
101 | 103 | encrypted_password, encryption_key = encrypt(password)
|
102 | 104 | redis_client.setex(storage_key, ttl, encrypted_password)
|
103 | 105 | encryption_key = encryption_key.decode('utf-8')
|
|
0 commit comments