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

Added support to configure the Oauth2 access token location in requests #388

Conversation

rhertogh
Copy link
Contributor

Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Fixed issues #386

This PR adds support for easy configuration of the location of the access token in API requests for Oauth 2 clients.
It also adds a "plain" oauth 2 client that uses the access token in the header by default as specified in RFC6749#section-7.

Copy link

what-the-diff bot commented Mar 23, 2024

PR Summary

  • Introduction of Access Token Locations for OAuth classes
    This PR introduces two new constants ACCESS_TOKEN_LOCATION_HEADER and ACCESS_TOKEN_LOCATION_BODY to each of the OAuth2.php, OpenIdConnect.php, GitHub.php, and TwitterOAuth2.php files. In result, this eases the configuration of where access tokens are placed in API requests, adding versatility to our access management.

  • Property Addition to OAuth classes
    A new property $accessTokenLocation has been added to the OAuth2.php and OpenIdConnect.php files. This feature enhances the ability to configure where the access token will be placed in API requests.

  • New OAuth2 Client
    The addition of a new file Oauth2Client.php will help manage OAuth2 authentication flow more effectively.

  • Unit Test Additions for Improved Robustness
    New test files for a variety of modules (FacebookTest.php, GitHubTest.php, GoogleHybridTest.php, GoogleTest.php, LinkedInTest.php, LiveTest.php, Oauth2ClientTest.php, OpenIdConnectTest.php, TwitterOAuth2Test.php, VKontakteTest.php, YandexTest.php) were added, enhancing the overall testing coverage. This measure ensures each module is functioning as expected and can prevent unwanted future bugs.

  • New Base Client Test Case
    A base test file BaseOauth2ClientTestCase.php has been added and includes methods that standardize OAuth2 client operations for testing: createClient(), getExpectedTokenLocation(), getAccessTokenHeaderTypeName(), getAccessTokenBodyParamName(), and testTokenLocation(). These additions should facilitate smoother, more consistent testing across all OAuth2 clients.

rhertogh and others added 2 commits March 23, 2024 19:39
…th2 access token location in requests and added a generic Oauth2 client)
src/OAuth2.php Outdated Show resolved Hide resolved
src/OAuth2.php Outdated Show resolved Hide resolved
src/OAuth2.php Outdated Show resolved Hide resolved
@rhertogh rhertogh requested a review from samdark March 26, 2024 00:48
@samdark samdark merged commit b9f753f into yiisoft:master Mar 26, 2024
9 of 10 checks passed
@samdark
Copy link
Member

samdark commented Mar 26, 2024

Thank you.

@samdark samdark added this to the 2.2.16 milestone Mar 26, 2024
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.

2 participants