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

Set approvedScopes attribute #225

Conversation

omarcinkonis
Copy link

@omarcinkonis omarcinkonis commented Oct 17, 2023

Fixes #224

Changes proposed in this pull request:

  • Set approvedScopes attribute as in socialite/src/Two/AbstractProvider.php:261

->setExpiresIn($this->parseExpiresIn($response));
->setRefreshToken($this->parseRefreshToken($response))
->setExpiresIn($this->parseExpiresIn($response))
->setApprovedScopes(explode($this->scopeSeparator, Arr::get($response, 'scope', '')));
Copy link
Member

Choose a reason for hiding this comment

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

Is the scope param always going to be a string?
Do all providers return this?

Copy link
Author

@omarcinkonis omarcinkonis Feb 5, 2024

Choose a reason for hiding this comment

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

https://datatracker.ietf.org/doc/html/rfc6749#section-3.3 proposed standard:
"scope" must be returned in response if the scopes granted don't match the scopes requested. Additional logic could be added to return requested scopes if "scope" is not set in response.

According to https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.4 - "scope" should always be a string of this format: scope-token *( SP scope-token )

Explanation:

  • scope-token - at least one scope-token
  • *( SP scope-token ) - optional 0 to many space delimited scope-tokens

However, this RFC is only proposed, also "scope" is retrieved from json, decoded in vendor/laravel/socialite/src/Two/AbstractProvider.php:299, so there is a chance it won't be a string.

A more defensive approach should be probably be implemented. I'll look into it, maybe I'll open a PR to https://github.com/laravel/socialite/blob/5.x/src/Two/AbstractProvider.php#L261

Copy link
Member

Choose a reason for hiding this comment

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

Happy to accept this PR, if you add a condition to check if it's a string first?

@omarcinkonis omarcinkonis marked this pull request as draft February 5, 2024 08:36
@atymic
Copy link
Member

atymic commented May 4, 2024

Closed in #229

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.

Set approvedScopes attribute as in Socialite
2 participants