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

How is OAuth2PKCEClient supposed to work? #406

Open
nclavaud opened this issue May 20, 2023 · 2 comments · May be fixed by #407
Open

How is OAuth2PKCEClient supposed to work? #406

nclavaud opened this issue May 20, 2023 · 2 comments · May be fixed by #407

Comments

@nclavaud
Copy link

Hi there,

I have been trying to implement PKCE with an unsupported provider (Zitadel) and had an issue with the authorization code exchange: the code challenge was always invalid (message invalid_grant, description invalid code challenge).

The OAuth2PKCEClient does generate a code challenge, but it is later overriden by league/oauth2-client AbstractProvider generating another one. As a result, the code challenge sent for authorization code exchange is not the same as before, hence the error.

With which provider is this OAuth2PKCEClient client class supposed to work?

@nclavaud
Copy link
Author

After a little further sought, I went to the conclusion that OAuth2PKCEClient should not be responsible for generating the PKCE code challenge. I will open a pull request with an alternative that works for my use-case.

@nclavaud
Copy link
Author

After more testing, things got clearer and here is the summary of what I have learned.

The league/oauth2-client package added support for PKCE in its latest version (2.7). It can be enabled by setting the pkceMethod option on the provider.

The current implementation of this bundle (v2.15.0) works well with the latest league/oauth2-client package (2.7.0) as long as the pkceMethod option is not defined on the provider.

However, if defined, the pkceMethod option set on the provider will conflict with the OAuth2PKCEClient class: both the client and the provider will generate a random code challenge (and they won't match, and no access token can be retrieved).

Two options:

  1. do not set the pkceMethod on the provider, it just works (the client class will be responsible of generating the code challenge)
  2. consider a pull request like fix: Make OAuth2PKCEClient work with latest league/oauth2-client release #407 to leverage the fact that league/oauth2-bundle now supports PKCE natively

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant