-
Notifications
You must be signed in to change notification settings - Fork 752
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
Send scope when requesting access tokens #1030
Conversation
Thanks @liayn, this fixed the issue I was having generating OAuth tokens using an identity provider from PingIdentity. |
Thank you for contributing! 🎉 |
Is this a breaking change? |
I think the problem is that the scope is usually only set in Only default scope:
Custom scope:
So either the integration needs to remember the tokens, or not send them. The best solution would probably be to only send the token if explicitly set, so not the default? |
Something like this (untested) public function getAccessToken($grant, array $options = [])
{
$grant = $this->verifyGrant($grant);
if (isset($options['scope']) && is_array($options['scope'])) {
$separator = $this->getScopeSeparator();
$options['scope'] = implode($separator, $options['scope']);
} |
It's always hard to define what is breaking and what not. If this now breaks for others this basically means that this worked by accident, and their default scopes where incorrect. To my (maybe limited) knowledge a lot of IdPs require the scopes to be sent together with the access token request. |
Thanks for looking into this. I don't have availability this weekend for a deep dive, perhaps a bit on Monday. 🤞 Given the potential severity and the time of the year 🧑🎄 I'd suggest to revert (part of) last release if details are unclear at the moment. On mollie we've shipped a temporary patch but I can imagine the impact is broader seeing other issues being reported here. |
I don't see the criticality yet. Until now I only see that people need to get their scopes right, which should have been correct ever since. For us this allowed to remove useless code: xperseguers/t3ext-oidc@38d7dfb As noted here it is only possible to get the default scopes from the GenericProvider, because it "violates" the visibility of the AbstractProvider. But of course, I'm curious if this caused other issues besides wrong default scopes. |
As far is I can tell, it's not about the default scopes. People using the default scopes should be fine, but when using custom scopes, they will be lost, depending on the implementation of the server. As far as I can tell, the Authorization URL defines the scopes and informs the user. The token request optionally allows the scope.
But a token request cannot inform the user, so it can cannot exceed the original scope tied to the authorization/refresh token. See the official examples, that are only mentioning the custom scopes for the getAuthorizationUrl https://github.com/thephpleague/oauth2-github?tab=readme-ov-file#managing-scopes I think the most common use of the token in the accessToken request is to limit the access to a subset. If not received it should fall back to the scopes granted in the Authorization URL.
I find this hard to believe, as this library has worked for hundreds of libraries before? I do see your linked documentation in #1029 where https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth-ropc#authorization-request describes this as Recommended. In my opininion, the Entra library should provide the default scopes if these are required, but it should not be done for all libraries and revert this. |
Also see the note for the Authorization Flow where it explicitly states that the usage op de scope parameter here is Microsoft extension to the authorization code flow (so not according to spec)
|
Thanks for the detailed explanation, I had a deeper look now. The patch was created a long time ago, so I had to dig into things again.
Indeed an interesting pointer I wasn't aware of. But honestly, this reads like a workaround/not intended usage of API to me, since the idea of the default scopes is exactly to contain the scopes used for the authorization URL. See 1 and 2 So I summarize for me:
Conclusions for me, if #1053 removes the default scopes again:
Probably the most optimal solution would be to:
Please let me know if my assessment is correct, or if I missed something. Thanks. |
Not sure what you mean by this:
I do agree that the usage of the I've looked more closely at your example and I see you use an abstraction there, but your workaround seemed okay to me. |
tl;dr I never intended a breaking change! Yes, lets fix this in the best way possible. Long version:
I mean that the examples do not make use of the "default scopes" feature. Upon init of the providers the "scopes" are not set via the constructor options.
Of course! As I said, this was really not meant as a breaking change, by any means! My goal is to fix the breaking issue and to still preserve my intended functionality as well, in a modified form, since I learned a lot about different usages throughout this conversation. From a dev's POV: Using a provider should be as simple as to set the intended scopes with the constructor options (aka "default scopes") and not care about them any further.
I presume you refer to https://github.com/xperseguers/t3ext-oidc/. Correct, this is the integration of OpenID Connect in the authentication system of TYPO3. The concrete provider actually used is not controlled by our integration. We offer the GenericProvider by default for ease of use, but TYPO3 site developers may load any other provider. The developer does (of course) not interact directly with this library here, otherwise t3ext-oidc would be pointless. => This library and the providers need to work seamless, obey to standards and to requirements made by the the actual IdP. |
So ZoHo Weble/ZohoClient#34 and google #1052 (comment) also seem to be affected, and Mollie was already reported |
Resolves: #1029