diff --git a/docs/source/conf.py b/docs/source/conf.py index fd2553e..595143d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -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. diff --git a/docs/source/index.rst b/docs/source/index.rst index 5c288b5..cafa5bd 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -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? +++++++++++++++++++++++++++ diff --git a/docs/source/pages/changelog.rst b/docs/source/pages/changelog.rst index a1956d8..935609f 100644 --- a/docs/source/pages/changelog.rst +++ b/docs/source/pages/changelog.rst @@ -4,6 +4,14 @@ Changelog The format is based on `Keep a Changelog `_ and this project adheres to `Semantic Versioning `_. +++++++++++++++++++++++++++ +Version 1.1.4 - 2018-08-06 +++++++++++++++++++++++++++ + +| **Fixed** +| - Bug with ``_do_protect`` in ``@scoped`` decorator +| + ++++++++++++++++++++++++++ Version 1.1.3 - 2018-08-06 ++++++++++++++++++++++++++ diff --git a/sanic_jwt/__init__.py b/sanic_jwt/__init__.py index a1564c3..a787e76 100644 --- a/sanic_jwt/__init__.py +++ b/sanic_jwt/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.1.3" +__version__ = "1.1.4" __author__ = "Adam Hopkins" __credits__ = "Richard Kuesters" diff --git a/sanic_jwt/decorators.py b/sanic_jwt/decorators.py index 9ea5723..5d1df30 100644 --- a/sanic_jwt/decorators.py +++ b/sanic_jwt/decorators.py @@ -27,12 +27,16 @@ 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: @@ -40,10 +44,10 @@ async def _do_protection(return_response=True, *args, **kwargs): 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: @@ -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( @@ -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 @@ -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": diff --git a/setup.py b/setup.py index d69ca89..95857ec 100644 --- a/setup.py +++ b/setup.py @@ -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",