Skip to content

Commit 0b56cd6

Browse files
authored
Merge pull request #146 from ahopkins/dev
Version 1.2.1 - 2018-12-04
2 parents eb4b55d + 73799af commit 0b56cd6

10 files changed

+63
-7
lines changed

docs/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
# The short X.Y version.
5757
version = u"1.2"
5858
# The full version, including alpha/beta/rc tags.
59-
release = u"1.2.0"
59+
release = u"1.2.1"
6060

6161
# The language for content autogenerated by Sphinx. Refer to documentation
6262
# for a list of supported languages.

docs/source/pages/changelog.rst

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ Changelog
44

55
The format is based on `Keep a Changelog <http://keepachangelog.com/en/1.0.0/>`_ and this project adheres to `Semantic Versioning <http://semver.org/spec/v2.0.0.html>`_.
66

7+
++++++++++++++++++++++++++
8+
Version 1.2.1 - 2018-12-04
9+
++++++++++++++++++++++++++
10+
11+
| **Fixed**
12+
| - `#143 <https://github.com/ahopkins/sanic-jwt/issues/143>`_. Security bug resolved on empty tokens
13+
|
14+
715
++++++++++++++++++++++++++
816
Version 1.2.0 - 2018-08-06
917
++++++++++++++++++++++++++

sanic_jwt/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.2.0"
1+
__version__ = "1.2.1"
22
__author__ = "Adam Hopkins"
33
__credits__ = "Richard Kuesters"
44

sanic_jwt/authentication.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def _get_token(self, request, refresh_token=False):
289289
"""
290290
if self.config.cookie_set():
291291
token = self._get_token_from_cookies(request, refresh_token)
292-
if token is not None:
292+
if token:
293293
return token
294294

295295
else:
@@ -298,15 +298,16 @@ def _get_token(self, request, refresh_token=False):
298298

299299
if self.config.query_string_set():
300300
token = self._get_token_from_query_string(request, refresh_token)
301-
if token is not None:
301+
if token:
302302
return token
303303

304304
else:
305305
if self.config.query_string_strict():
306306
raise exceptions.MissingAuthorizationQueryArg()
307307

308308
token = self._get_token_from_headers(request, refresh_token)
309-
if token is not None:
309+
310+
if token:
310311
return token
311312

312313
raise exceptions.MissingAuthorizationHeader()

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
setup(
2020
name="sanic-jwt",
21-
version="1.2.0",
21+
version="1.2.1",
2222
description="JWT oauth flow for Sanic",
2323
url="https://github.com/ahopkins/sanic-jwt",
2424
download_url="https://github.com/ahopkins/sanic-jwt/archive/master.zip",

tests/test_endpoints_basic.py

+20
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ def test_auth_verify_missing_token_debug(app):
7272
assert "Authorization header not present." in response.json.get("reasons")
7373

7474

75+
def test_auth_verify_invalid_token(app):
76+
sanic_app, _ = app
77+
_, response = sanic_app.test_client.get(
78+
"/auth/verify", headers={"Authorization": "Bearer "}
79+
)
80+
assert response.status == 400
81+
assert response.json.get("exception") == "InvalidAuthorizationHeader"
82+
assert "Authorization header is invalid." in response.json.get("reasons")
83+
84+
85+
def test_auth_verify_invalid_token(app):
86+
sanic_app, _ = app
87+
_, response = sanic_app.test_client.get(
88+
"/auth/verify", headers={"Authorization": "Bearer "}
89+
)
90+
assert response.status == 401
91+
assert response.json.get("exception") == "MissingAuthorizationHeader"
92+
assert "Authorization header not present." in response.json.get("reasons")
93+
94+
7595
def test_auth_refresh_not_found(app):
7696
sanic_app, _ = app
7797
_, response = sanic_app.test_client.post("/auth/refresh")

tests/test_endpoints_cookies.py

+13
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,16 @@ def test_refresh_token_with_cookies_not_strict(
365365
sanicjwt.config.cookie_refresh_token_name(), None
366366
) is None # there is no new refresh token
367367
assert sanicjwt.config.cookie_refresh_token_name() not in response.json
368+
369+
def test_auth_verify_invalid_token(self, app_with_refresh_token):
370+
sanic_app, sanicjwt = app_with_refresh_token
371+
372+
_, response = sanic_app.test_client.get(
373+
"/auth/verify",
374+
cookies={sanicjwt.config.cookie_access_token_name(): ""},
375+
)
376+
assert response.status == 401
377+
assert response.json.get("exception") == "MissingAuthorizationCookie"
378+
assert "Authorization cookie not present." in response.json.get(
379+
"reasons"
380+
)

tests/test_endpoints_query_string.py

+14
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,17 @@ def test_refresh_token_with_query_string_not_strict(
334334
sanicjwt.config.query_string_refresh_token_name(), None
335335
) is None # there is no new refresh token
336336
assert sanicjwt.config.query_string_refresh_token_name() not in response.json
337+
338+
def test_auth_verify_invalid_token(self, app_with_refresh_token):
339+
sanic_app, sanicjwt = app_with_refresh_token
340+
341+
_, response = sanic_app.test_client.get(
342+
"/auth/verify?{}=".format(
343+
sanicjwt.config.cookie_access_token_name()
344+
)
345+
)
346+
assert response.status == 401
347+
assert response.json.get("exception") == "MissingAuthorizationQueryArg"
348+
assert "Authorization query argument not present." in response.json.get(
349+
"reasons"
350+
)

tests/test_static.py

Whitespace-only changes.

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ commands =
5959
deps = coverage
6060
skip_install = true
6161
commands =
62-
; coverage combine --append
62+
coverage combine --append
6363
coverage report
6464
coverage html
6565

0 commit comments

Comments
 (0)