File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 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():
141141 header_type = config .header_type
142142
143143 # 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 ( "," )
145145 if not auth_header :
146146 raise NoAuthorizationError ("Missing {} Header" .format (header_name ))
147147
Original file line number Diff line number Diff line change @@ -54,6 +54,18 @@ def test_default_headers(app):
5454 assert response .get_json () == {"foo" : "bar" }
5555
5656
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+
5769def test_custom_header_name (app ):
5870 app .config ["JWT_HEADER_NAME" ] = "Foo"
5971 test_client = app .test_client ()
You can’t perform that action at this time.
0 commit comments