Skip to content

Commit 4013c73

Browse files
Allow flask 2.x.x (#427)
1 parent 3ecf2c0 commit 4013c73

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

examples/automatic_user_loading.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from hmac import compare_digest
2+
13
from flask import Flask
24
from flask import jsonify
35
from flask import request
46
from flask_sqlalchemy import SQLAlchemy
5-
from werkzeug.security import safe_str_cmp
67

78
from flask_jwt_extended import create_access_token
89
from flask_jwt_extended import current_user
@@ -29,7 +30,7 @@ class User(db.Model):
2930

3031
# NOTE: In a real application make sure to properly hash and salt passwords
3132
def check_password(self, password):
32-
return safe_str_cmp(password, "password")
33+
return compare_digest(password, "password")
3334

3435

3536
# Register a callback function that takes whatever object is passed in as the

flask_jwt_extended/tokens.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from datetime import datetime
33
from datetime import timedelta
44
from datetime import timezone
5+
from hmac import compare_digest
56

67
import jwt
7-
from werkzeug.security import safe_str_cmp
88

99
from flask_jwt_extended.exceptions import CSRFError
1010
from flask_jwt_extended.exceptions import JWTDecodeError
@@ -110,7 +110,7 @@ def _decode_jwt(
110110
if csrf_value:
111111
if "csrf" not in decoded_token:
112112
raise JWTDecodeError("Missing claim: csrf")
113-
if not safe_str_cmp(decoded_token["csrf"], csrf_value):
113+
if not compare_digest(decoded_token["csrf"], csrf_value):
114114
raise CSRFError("CSRF double submit tokens do not match")
115115

116116
return decoded_token

requirements.txt

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,64 @@
11
alabaster==0.7.12
22
appdirs==1.4.4
3-
Babel==2.9.0
3+
Babel==2.9.1
44
black==20.8b1
55
bleach==3.3.0
66
certifi==2020.12.5
7-
cffi==1.14.4
7+
cffi==1.14.5
88
cfgv==3.2.0
99
chardet==4.0.0
10-
click==7.1.2
10+
click==8.0.0
1111
colorama==0.4.4
12-
cryptography==3.3.2
12+
cryptography==3.4.7
1313
distlib==0.3.1
14-
docutils==0.16
14+
docutils==0.17.1
1515
filelock==3.0.12
16-
Flask==1.1.2
17-
identify==1.5.13
16+
Flask==2.0.0
17+
identify==2.2.4
1818
idna==2.10
1919
imagesize==1.2.0
20-
itsdangerous==1.1.0
20+
importlib-metadata==4.0.1
21+
itsdangerous==2.0.0
2122
Jinja2==2.11.3
22-
keyring==21.8.0
23+
keyring==23.0.1
2324
MarkupSafe==1.1.1
2425
mypy-extensions==0.4.3
25-
nodeenv==1.5.0
26-
packaging==20.8
27-
Pallets-Sphinx-Themes==1.2.3
26+
nodeenv==1.6.0
27+
packaging==20.9
28+
Pallets-Sphinx-Themes==2.0.0
2829
pathspec==0.8.1
2930
pkginfo==1.7.0
3031
pluggy==0.13.1
31-
pre-commit==2.9.3
32+
pre-commit==2.12.1
3233
py==1.10.0
3334
pycparser==2.20
34-
Pygments==2.7.4
35-
PyJWT==2.0.1
35+
Pygments==2.9.0
36+
PyJWT==2.1.0
3637
pyparsing==2.4.7
37-
pytz==2020.5
38-
PyYAML==5.4
39-
readme-renderer==28.0
40-
regex==2020.11.13
38+
pytz==2021.1
39+
PyYAML==5.4.1
40+
readme-renderer==29.0
41+
regex==2021.4.4
4142
requests==2.25.1
4243
requests-toolbelt==0.9.1
43-
rfc3986==1.4.0
44-
six==1.15.0
45-
snowballstemmer==2.0.0
46-
Sphinx==3.4.3
44+
rfc3986==1.5.0
45+
six==1.16.0
46+
snowballstemmer==2.1.0
47+
Sphinx==4.0.1
4748
sphinxcontrib-applehelp==1.0.2
4849
sphinxcontrib-devhelp==1.0.2
4950
sphinxcontrib-htmlhelp==1.0.3
5051
sphinxcontrib-jsmath==1.0.1
5152
sphinxcontrib-qthelp==1.0.3
5253
sphinxcontrib-serializinghtml==1.1.4
5354
toml==0.10.2
54-
tox==3.21.1
55-
tqdm==4.56.0
56-
twine==3.3.0
57-
typed-ast==1.4.2
58-
typing-extensions==3.7.4.3
55+
tox==3.23.1
56+
tqdm==4.60.0
57+
twine==3.4.1
58+
typed-ast==1.4.3
59+
typing-extensions==3.10.0.0
5960
urllib3==1.26.4
60-
virtualenv==20.3.1
61+
virtualenv==20.4.6
6162
webencodings==0.5.1
62-
Werkzeug==1.0.1
63+
Werkzeug==2.0.0
64+
zipp==3.4.1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
platforms="any",
2828
install_requires=[
2929
"Werkzeug>=0.14", # Needed for SameSite cookie functionality
30-
"Flask>=1.0,<2.0",
30+
"Flask>=1.0,<3.0",
3131
"PyJWT>=2.0,<3.0",
3232
],
3333
extras_require={"asymmetric_crypto": ["cryptography>=3.0,<4.0"]},

0 commit comments

Comments
 (0)