Skip to content

Commit 11b1272

Browse files
lukasz-walkiewiczebyhr
authored andcommitted
Fix multiple challenges handling in OAuth2
1 parent 2a23b72 commit 11b1272

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

tests/unit/test_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ def test_oauth2_authentication_missing_headers(header, error):
421421
'Bearer x_redirect_server="{redirect_server}", x_token_server="{token_server}", additional_challenge',
422422
'Bearer x_redirect_server="{redirect_server}", x_token_server="{token_server}", additional_challenge="value"',
423423
'Bearer x_token_server="{token_server}", x_redirect_server="{redirect_server}"',
424+
'Basic realm="Trino", Bearer x_redirect_server="{redirect_server}", x_token_server="{token_server}"',
425+
'Bearer x_redirect_server="{redirect_server}", x_token_server="{token_server}", Basic realm="Trino"',
424426
])
425427
@httprettified
426428
def test_oauth2_header_parsing(header, sample_post_response_data):

trino/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _authenticate(self, response, **kwargs):
190190
if not auth_info:
191191
raise exceptions.TrinoAuthError("Error: header WWW-Authenticate not available in the response.")
192192

193-
if not _OAuth2TokenBearer._BEARER_PREFIX.match(auth_info):
193+
if not _OAuth2TokenBearer._BEARER_PREFIX.search(auth_info):
194194
raise exceptions.TrinoAuthError(f"Error: header info didn't match {auth_info}")
195195

196196
auth_info_headers = parse_dict_header(_OAuth2TokenBearer._BEARER_PREFIX.sub("", auth_info, count=1))

0 commit comments

Comments
 (0)