Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions flask_jwt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from flask import current_app, request, jsonify, _request_ctx_stack
from werkzeug.local import LocalProxy
from werkzeug.exceptions import BadRequest

__version__ = '0.3.2'

Expand All @@ -38,7 +39,8 @@
'JWT_EXPIRATION_DELTA': timedelta(seconds=300),
'JWT_NOT_BEFORE_DELTA': timedelta(seconds=0),
'JWT_VERIFY_CLAIMS': ['signature', 'exp', 'nbf', 'iat'],
'JWT_REQUIRED_CLAIMS': ['exp', 'iat', 'nbf']
'JWT_REQUIRED_CLAIMS': ['exp', 'iat', 'nbf'],
'TRAP_BAD_REQUEST_ERRORS': True,
}


Expand Down Expand Up @@ -179,8 +181,11 @@ def decorator(*args, **kwargs):
return wrapper


class JWTError(Exception):
class JWTError(BadRequest):
# class JWTError(Exception):
def __init__(self, error, description, status_code=401, headers=None):
# HTTPException.__init__(
# self=self, description=description, response=None)
self.error = error
self.description = description
self.status_code = status_code
Expand Down Expand Up @@ -219,7 +224,7 @@ def init_app(self, app):
for k, v in CONFIG_DEFAULTS.items():
app.config.setdefault(k, v)
app.config.setdefault('JWT_SECRET_KEY', app.config['SECRET_KEY'])

app.config['TRAP_BAD_REQUEST_ERRORS'] = True
auth_url_rule = app.config.get('JWT_AUTH_URL_RULE', None)

if auth_url_rule:
Expand Down