From 99593d4096e0718ab4765f81f2885b07b5d16d08 Mon Sep 17 00:00:00 2001 From: Vasily Chinarev Date: Tue, 5 Apr 2016 13:34:51 +0300 Subject: [PATCH 1/2] Returned support for JWT_AUTH_ENDPOINT As of 0.3.2 flask_jwt creates an endpoint named '_default_auth_request_handler', no matter what JWT_AUTH_ENDPOINT is --- flask_jwt/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flask_jwt/__init__.py b/flask_jwt/__init__.py index f864b78..8cf018a 100644 --- a/flask_jwt/__init__.py +++ b/flask_jwt/__init__.py @@ -221,8 +221,9 @@ def init_app(self, app): app.config.setdefault('JWT_SECRET_KEY', app.config['SECRET_KEY']) auth_url_rule = app.config.get('JWT_AUTH_URL_RULE', None) + endpoint = app.config.get('JWT_AUTH_ENDPOINT', None) - if auth_url_rule: + if auth_url_rule and endpoint: if self.auth_request_callback == _default_auth_request_handler: assert self.authentication_callback is not None, ( 'an authentication_handler function must be defined when using the built in ' @@ -230,6 +231,7 @@ def init_app(self, app): auth_url_options = app.config.get('JWT_AUTH_URL_OPTIONS', {'methods': ['POST']}) auth_url_options.setdefault('view_func', self.auth_request_callback) + auth_url_options.setdefault('endpoint', endpoint) app.add_url_rule(auth_url_rule, **auth_url_options) app.errorhandler(JWTError)(self._jwt_error_callback) From ae0421745eb3073a1a718d5347229f88de52b519 Mon Sep 17 00:00:00 2001 From: Vasily Chinarev Date: Tue, 5 Apr 2016 13:38:54 +0300 Subject: [PATCH 2/2] Added test for JWT_AUTH_ENDPOINT support --- tests/test_jwt.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_jwt.py b/tests/test_jwt.py index 2157003..a4a946d 100644 --- a/tests/test_jwt.py +++ b/tests/test_jwt.py @@ -46,7 +46,9 @@ def test_adds_auth_endpoint(): app.config['JWT_AUTH_ENDPOINT'] = 'jwt_auth' flask_jwt.JWT(app, lambda: None, lambda: None) rules = [str(r) for r in app.url_map._rules] + endpoints = [r.endpoint for r in app.url_map.iter_rules()] assert '/auth' in rules + assert 'jwt_auth' in endpoints def test_auth_endpoint_with_valid_request(client, user):