Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix www-authenticate header parsing bug when refreshing tokens #485

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

JonMerlevede
Copy link
Contributor

Description

This PR applies a minimal change to fix the issue where the OAuth refresh token flow results in the "Header info didn't have x_token_server" error:

trino.exceptions.TrinoAuthError: Error: header info didn't have x_token_server

This error was introduced in #467. The regression was not captured by the test test_oauth2_refresh_token_flow; Trino returns multi-valued Www-Authenticate headers while PostStatementCallback does not, and the new parsing logic does not handle this appropriately. This PR also updates the test.

Non-technical explanation

This PR fixes the issue where Trino returns "Header info didn't have x_token_server" after some time and starts working again after a longer time.

Release notes

( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text:

* Fixes "header info didn't have x_token_server" error. ({issue}`484`)

Copy link

cla-bot bot commented Sep 13, 2024

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@JonMerlevede JonMerlevede changed the title Bugfix/missing x token server Fix "header info didn't have x_token_server" bug Sep 13, 2024
@JonMerlevede JonMerlevede changed the title Fix "header info didn't have x_token_server" bug Fix bug in parsing of www-authenticate header when refreshing tokens Sep 13, 2024
@JonMerlevede JonMerlevede changed the title Fix bug in parsing of www-authenticate header when refreshing tokens Fix www-authenticate header parsing bug when refreshing tokens Sep 13, 2024
@hashhar
Copy link
Member

hashhar commented Sep 14, 2024

please see ci complaints and squash the commits into one Fix parsing of www-authenticate header since it's a single logical change (tests + impl go together).

Thanks for the PR.

@hashhar hashhar requested a review from hovaesco September 14, 2024 11:22
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % ci and commit

@JonMerlevede JonMerlevede force-pushed the bugfix/missing-x_token_server branch from 7b6bd59 to e1ce8bc Compare September 17, 2024 11:09
Copy link

cla-bot bot commented Sep 17, 2024

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@JonMerlevede JonMerlevede force-pushed the bugfix/missing-x_token_server branch from e1ce8bc to 3f9a64d Compare September 17, 2024 11:10
Copy link

cla-bot bot commented Sep 17, 2024

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@JonMerlevede JonMerlevede force-pushed the bugfix/missing-x_token_server branch from 3f9a64d to 1bd210b Compare September 18, 2024 20:17
@cla-bot cla-bot bot added the cla-signed label Sep 18, 2024
For multi-valued www-authenticate headers the previous code could throw:

    trino.exceptions.TrinoAuthError: Error: header info didn't have x_token_server
@hashhar hashhar force-pushed the bugfix/missing-x_token_server branch from 1bd210b to 8eade11 Compare September 26, 2024 09:02
@hashhar
Copy link
Member

hashhar commented Sep 26, 2024

reworded the commit message. Will merge on CI done.

@hashhar hashhar merged commit 7377764 into trinodb:master Sep 26, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants