File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ def _decode_jwt_from_headers():
141
141
header_type = config .header_type
142
142
143
143
# Verify we have the auth header
144
- auth_header = request .headers .get (header_name , None )
144
+ auth_header = request .headers .get (header_name , "" ). strip (). strip ( "," )
145
145
if not auth_header :
146
146
raise NoAuthorizationError ("Missing {} Header" .format (header_name ))
147
147
Original file line number Diff line number Diff line change @@ -54,6 +54,18 @@ def test_default_headers(app):
54
54
assert response .get_json () == {"foo" : "bar" }
55
55
56
56
57
+ def test_header_with_trailing_spaces_and_commas (app ):
58
+ test_client = app .test_client ()
59
+
60
+ with app .test_request_context ():
61
+ access_token = create_access_token ("username" )
62
+
63
+ access_headers = {"Authorization" : "Bearer {}, " .format (access_token )}
64
+ response = test_client .get ("/protected" , headers = access_headers )
65
+ assert response .status_code == 200
66
+ assert response .get_json () == {"foo" : "bar" }
67
+
68
+
57
69
def test_custom_header_name (app ):
58
70
app .config ["JWT_HEADER_NAME" ] = "Foo"
59
71
test_client = app .test_client ()
You can’t perform that action at this time.
0 commit comments