Skip to content

Commit

Permalink
Fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Filienko committed Aug 8, 2024
1 parent 1df20e0 commit 607c6d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
19 changes: 8 additions & 11 deletions jwt_proxy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
blueprint = Blueprint('auth', __name__)
SUPPORTED_METHODS = ('GET', 'POST', 'PUT', 'DELETE', 'OPTIONS')

# Workaround no JSON representation for datetime.timedelta
class CustomJSONProvider(DefaultJSONProvider):
def __init__(self, app):
super().__init__(app)

def default(self, o):
return str(o)


def proxy_request(req, upstream_url, user_info=None):
"""Forward request to given url"""
Expand Down Expand Up @@ -95,17 +103,6 @@ def smart_configuration():
@blueprint.route("/settings/<string:config_key>")
def config_settings(config_key):
"""Non-secret application settings"""

# workaround no JSON representation for datetime.timedelta
class CustomJSONProvider(DefaultJSONProvider):
def __init__(self, app):
super().__init__(app)

def default(self, o):
return str(o)

current_app.json = CustomJSONProvider

# return selective keys - not all can be be viewed by users, e.g.secret key
blacklist = ("SECRET", "KEY")

Expand Down
3 changes: 2 additions & 1 deletion jwt_proxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

from jwt_proxy import api
from jwt_proxy.audit import audit_log_init, audit_entry

from jwt_proxy.api import CustomJSONProvider

def create_app(testing=False, cli=False):
"""Application factory, used to create application"""
app = Flask("jwt_proxy")
app.json = CustomJSONProvider
register_blueprints(app)
configure_app(app)

Expand Down

0 comments on commit 607c6d0

Please sign in to comment.