Skip to content

Commit 607c6d0

Browse files
committed
Fixing
1 parent 1df20e0 commit 607c6d0

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

jwt_proxy/api.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
blueprint = Blueprint('auth', __name__)
1010
SUPPORTED_METHODS = ('GET', 'POST', 'PUT', 'DELETE', 'OPTIONS')
1111

12+
# Workaround no JSON representation for datetime.timedelta
13+
class CustomJSONProvider(DefaultJSONProvider):
14+
def __init__(self, app):
15+
super().__init__(app)
16+
17+
def default(self, o):
18+
return str(o)
19+
1220

1321
def proxy_request(req, upstream_url, user_info=None):
1422
"""Forward request to given url"""
@@ -95,17 +103,6 @@ def smart_configuration():
95103
@blueprint.route("/settings/<string:config_key>")
96104
def config_settings(config_key):
97105
"""Non-secret application settings"""
98-
99-
# workaround no JSON representation for datetime.timedelta
100-
class CustomJSONProvider(DefaultJSONProvider):
101-
def __init__(self, app):
102-
super().__init__(app)
103-
104-
def default(self, o):
105-
return str(o)
106-
107-
current_app.json = CustomJSONProvider
108-
109106
# return selective keys - not all can be be viewed by users, e.g.secret key
110107
blacklist = ("SECRET", "KEY")
111108

jwt_proxy/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
from jwt_proxy import api
66
from jwt_proxy.audit import audit_log_init, audit_entry
7-
7+
from jwt_proxy.api import CustomJSONProvider
88

99
def create_app(testing=False, cli=False):
1010
"""Application factory, used to create application"""
1111
app = Flask("jwt_proxy")
12+
app.json = CustomJSONProvider
1213
register_blueprints(app)
1314
configure_app(app)
1415

0 commit comments

Comments
 (0)