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: Less restrictive content-type header check for google authentication (ignores charset) #1382

Merged

Conversation

DanieleQuasimodo
Copy link
Contributor

Less restrictive content-type header check for google authentication (now only the media-type is compared, ignoring charset, boundary, etc).
Should fix issue #1089.

Implemented as suggested in PEP-594 (due to deprecation of cgi.parse_header. See https://peps.python.org/pep-0594/#cgi).

@DanieleQuasimodo DanieleQuasimodo requested review from a team as code owners September 18, 2023 16:04
@google-cla
Copy link

google-cla bot commented Sep 18, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@DanieleQuasimodo DanieleQuasimodo changed the title Less restrictive content-type header check for google authentication (ignores charset) Fix: Less restrictive content-type header check for google authentication (ignores charset) Sep 18, 2023
@arithmetic1728 arithmetic1728 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 18, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 18, 2023
@arithmetic1728
Copy link
Contributor

@DanieleQuasimodo
Copy link
Contributor Author

@DanieleQuasimodo thank you for your PR. Could you add some unit tests to cover your change (for example, https://github.com/googleapis/google-auth-library-python/blob/main/tests/test__helpers.py and https://github.com/googleapis/google-auth-library-python/blob/main/tests/compute_engine/test__metadata.py).

Sure, no problem! Yesterday I was a bit rushed and completely forgot about it.
I'll get some tests written as soon as I find a moment.

@DanieleQuasimodo DanieleQuasimodo force-pushed the better-content-type-check branch from 3b544e2 to 6b96023 Compare September 23, 2023 10:54
@DanieleQuasimodo DanieleQuasimodo force-pushed the better-content-type-check branch from 6b96023 to bda4f39 Compare September 23, 2023 10:57
@DanieleQuasimodo
Copy link
Contributor Author

DanieleQuasimodo commented Sep 23, 2023

These should do.
The _metadata test is probably a bit redundant (_metadata inner workings haven't really changed except for invoking the new function, which is already tested in the _helpers tests), but I still added it, just in case.

The forced push to my fork was just because I'm dumb, committed with the wrong account and had to ammend the author (so Google CLA is happy) 😅

@arithmetic1728 arithmetic1728 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 24, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 24, 2023
@arithmetic1728
Copy link
Contributor

@DanieleQuasimodo The PR looks great, thanks! Could you run python -m nox -s lint to format the files (this caused kokoro build failure)? After that I will go ahead to merge the PR.

@DanieleQuasimodo
Copy link
Contributor Author

@arithmetic1728 I think now it should be ok.
I ran both blacken and lint

@arithmetic1728 arithmetic1728 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 25, 2023
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Sep 25, 2023
@arithmetic1728 arithmetic1728 added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2023
@arithmetic1728 arithmetic1728 merged commit 7039beb into googleapis:main Sep 25, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants