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: Ensure autogenerate_code_verifier defaults to True in from_client_config #356

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Perun108
Copy link

@Perun108 Perun108 commented Jun 11, 2024

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #354 🦕

@Perun108 Perun108 requested review from a team as code owners June 11, 2024 21:01
@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Jun 11, 2024
@@ -161,6 +161,8 @@ def from_client_config(cls, client_config, scopes, **kwargs):
# these args cannot be passed to requests_oauthlib.OAuth2Session
code_verifier = kwargs.pop("code_verifier", None)
autogenerate_code_verifier = kwargs.pop("autogenerate_code_verifier", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
autogenerate_code_verifier = kwargs.pop("autogenerate_code_verifier", None)
autogenerate_code_verifier = kwargs.pop("autogenerate_code_verifier", True)

Comment on lines 164 to 165
if not code_verifier and autogenerate_code_verifier is None:
autogenerate_code_verifier = True
Copy link
Contributor

Choose a reason for hiding this comment

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

I think let's revert this, and instead add a guard in the autogenerate logic.

@clundin25
Copy link
Contributor

Not sure I am doing something wrong here, but I cannot leave a comment on this line. Maybe because your PR does not touch it?

Instead, I think we should change line 242 to:

if self.code_verifier is None and self.autogenerate_code_verifier:

My thoughts are:

  1. We want to use PKCE as much as possible.
  2. This keeps the logic near where the variables are used, so other refactors don't accidentally revert this behavior and new constructors don't have to repeat this check.

@Perun108 what are your thoughts?

@Perun108
Copy link
Author

@clundin25 Thank you so much for the suggestions. They make total sense. I updated my PR accordingly, please review. Thanks!

@clundin25
Copy link
Contributor

Thank you @Perun108 for your contribution! This looks great! Would you mind fixing the unit tests?

@Perun108
Copy link
Author

Perun108 commented Jul 5, 2024

@clundin25 Thank you, I'm so happy you found my little contribution valuable. Sure, I will try to fix the unit tests, but it will probably take me some time to figure out how the tests are set up and how the objects are mocked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xs Pull request size is extra small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flow.autogenerate_code_verifier does not default to True and flow.code_verifier is None
3 participants