Skip to content

Commit

Permalink
Merge pull request #124 from ahopkins/dev
Browse files Browse the repository at this point in the history
Version 1.1.4 - 2018-08-06
  • Loading branch information
ahopkins committed Aug 6, 2018
2 parents bfd4263 + 9a8deb4 commit 7888f9a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# The short X.Y version.
version = u"1.1"
# The full version, including alpha/beta/rc tags.
release = u"1.1.3"
release = u"1.1.4"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
4 changes: 4 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Flexibility is really the name of the game for v. 1.1. Most of the features are

Checkout the changelog for a more detailed description.

.. note::

It is recommended that you are at least using **version 1.1.2**. You can upgrade to **version 1.1.4** for improved exception handling and some bug fixes.

+++++++++++++++++++++++++++
What is new in Version 1.0?
+++++++++++++++++++++++++++
Expand Down
8 changes: 8 additions & 0 deletions docs/source/pages/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Changelog

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>`_.

++++++++++++++++++++++++++
Version 1.1.4 - 2018-08-06
++++++++++++++++++++++++++

| **Fixed**
| - Bug with ``_do_protect`` in ``@scoped`` decorator
|
++++++++++++++++++++++++++
Version 1.1.3 - 2018-08-06
++++++++++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion sanic_jwt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.1.3"
__version__ = "1.1.4"
__author__ = "Adam Hopkins"
__credits__ = "Richard Kuesters"

Expand Down
19 changes: 12 additions & 7 deletions sanic_jwt/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@ def instant_config(instance, **kwargs):
clear_cache()


async def _do_protection(return_response=True, *args, **kwargs):
async def _do_protection(*args, **kwargs):
initialized_on = kwargs.pop("initialized_on")
kw = kwargs.pop("kw")
request = kwargs.pop("request")
f = kwargs.pop("f")

use_kwargs = deepcopy(kwargs)
if 'return_response' in use_kwargs:
use_kwargs.pop('return_response')

if initialized_on and isinstance(initialized_on, Blueprint):
instance = initialized_on
else:
instance = request.app

with instant_config(instance, request=request, **kw):
if request.method == "OPTIONS":
response = f(request, *args, **kwargs)
response = f(request, *args, **use_kwargs)
if isawaitable(response): # noqa
response = await response
if return_response:
if kwargs.get('return_response', True):
return response

else:
Expand All @@ -53,7 +57,7 @@ async def _do_protection(return_response=True, *args, **kwargs):
(
is_authenticated, status, reasons
) = instance.auth._check_authentication(
request, request_args=args, request_kwargs=kwargs
request, request_args=args, request_kwargs=use_kwargs
)
except AttributeError:
raise exceptions.SanicJWTException(
Expand All @@ -71,8 +75,8 @@ async def _do_protection(return_response=True, *args, **kwargs):
) else e.args[0]

if is_authenticated:
if return_response:
response = f(request, *args, **kwargs)
if kwargs.get('return_response', True):
response = f(request, *args, **use_kwargs)
if isawaitable(response):
response = await response
return response
Expand Down Expand Up @@ -124,10 +128,11 @@ async def decorated_function(request, *args, **kwargs):
"kw": kw,
"request": request,
"f": f,
"return_response": False,
}
)
_, instance = await _do_protection(
return_response=False, *args, **protect_kwargs
*args, **protect_kwargs
)

if request.method == "OPTIONS":
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

setup(
name="sanic-jwt",
version="1.1.3",
version="1.1.4",
description="JWT oauth flow for Sanic",
url="https://github.com/ahopkins/sanic-jwt",
download_url="https://github.com/ahopkins/sanic-jwt/archive/master.zip",
Expand Down

0 comments on commit 7888f9a

Please sign in to comment.