From 3f62ab9151e366a0b04dec39891f9de361a75418 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Tue, 12 Sep 2017 17:17:00 +0200 Subject: [PATCH 01/13] Amazon Provider added --- README.md | 17 ++++++ src/Client/Provider/AmazonClient.php | 34 ++++++++++++ .../KnpUOAuth2ClientExtension.php | 2 + .../Providers/AmazonProviderConfigurator.php | 54 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 src/Client/Provider/AmazonClient.php create mode 100644 src/DependencyInjection/Providers/AmazonProviderConfigurator.php diff --git a/README.md b/README.md index c2971775..cb9d2f78 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ via Composer: | OAuth2 Provider | Install | | --------------------------------------------------------------------- | ------------------------------------------------------ | +| [Amazon](https://github.com/luchianenco/oauth2-amazon) | composer require luchianenco/oauth2-amazon | | [Auth0](https://github.com/RiskioFr/oauth2-auth0) | composer require riskio/oauth2-auth0 | | [Azure](https://github.com/thenetworg/oauth2-azure) | composer require thenetworg/oauth2-azure | | [Bitbucket](https://github.com/stevenmaguire/oauth2-bitbucket) | composer require stevenmaguire/oauth2-bitbucket | @@ -326,6 +327,22 @@ any provider. # app/config/config.yml knpu_oauth2_client: clients: + # will create service: "knpu.oauth2.client.amazon" + # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\AmazonClient + # composer require luchianenco/oauth2-amazon + amazon: + # must be "amazon" - it activates that type! + type: amazon + # add and configure client_id and client_secret in parameters.yml + client_id: %amazon_client_id% + client_secret: %amazon_client_secret% + # a route name you'll create + redirect_route: connect_amazon_check + redirect_params: {} + + # whether to check OAuth2 "state": defaults to true + # use_state: true + # will create service: "knpu.oauth2.client.auth0" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\Auth0Client # composer require riskio/oauth2-auth0 diff --git a/src/Client/Provider/AmazonClient.php b/src/Client/Provider/AmazonClient.php new file mode 100644 index 00000000..51a6c85a --- /dev/null +++ b/src/Client/Provider/AmazonClient.php @@ -0,0 +1,34 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace KnpU\OAuth2ClientBundle\Client\Provider; + +use KnpU\OAuth2ClientBundle\Client\OAuth2Client; +use League\OAuth2\Client\Token\AccessToken; +use Luchianenco\OAuth2\Client\Provider\AmazonResourceOwner; + +class AmazonClient extends OAuth2Client +{ + /** + * @param AccessToken $accessToken + * @return AmazonResourceOwner + */ + public function fetchUserFromToken(AccessToken $accessToken) + { + return parent::fetchUserFromToken($accessToken); + } + + /** + * @return AmazonResourceOwner + */ + public function fetchUser() + { + return parent::fetchUser(); + } +} \ No newline at end of file diff --git a/src/DependencyInjection/KnpUOAuth2ClientExtension.php b/src/DependencyInjection/KnpUOAuth2ClientExtension.php index 9fd51387..90f1fcea 100644 --- a/src/DependencyInjection/KnpUOAuth2ClientExtension.php +++ b/src/DependencyInjection/KnpUOAuth2ClientExtension.php @@ -10,6 +10,7 @@ namespace KnpU\OAuth2ClientBundle\DependencyInjection; +use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\AmazonProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\Auth0ProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\AzureProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\BitbucketProviderConfigurator; @@ -54,6 +55,7 @@ class KnpUOAuth2ClientExtension extends Extension /** @var array */ private static $supportedProviderTypes = [ + 'amazon' => AmazonProviderConfigurator::class, 'auth0' => Auth0ProviderConfigurator::class, 'azure' => AzureProviderConfigurator::class, 'bitbucket' => BitbucketProviderConfigurator::class, diff --git a/src/DependencyInjection/Providers/AmazonProviderConfigurator.php b/src/DependencyInjection/Providers/AmazonProviderConfigurator.php new file mode 100644 index 00000000..86ca6d67 --- /dev/null +++ b/src/DependencyInjection/Providers/AmazonProviderConfigurator.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace KnpU\OAuth2ClientBundle\DependencyInjection\Providers; + +use Symfony\Component\Config\Definition\Builder\NodeBuilder; + +class AmazonProviderConfigurator implements ProviderConfiguratorInterface +{ + public function buildConfiguration(NodeBuilder $node) + { + // no custom options + } + + public function getProviderClass(array $config) + { + return 'Luchianenco\OAuth2\Client\Provider\Amazon'; + } + + public function getProviderOptions(array $config) + { + return [ + 'clientId' => $config['client_id'], + 'clientSecret' => $config['client_secret'], + ]; + } + + public function getPackagistName() + { + return 'luchianenco/oauth2-amazon'; + } + + public function getLibraryHomepage() + { + return 'https://github.com/luchianenco/oauth2-amazon'; + } + + public function getProviderDisplayName() + { + return 'Amazon'; + } + + public function getClientClass(array $config) + { + return 'KnpU\OAuth2ClientBundle\Client\Provider\AmazonClient'; + } +} \ No newline at end of file From 8a25ab742ba6a582e2b5d7f02cc4a30733c09b2a Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Sat, 7 Oct 2017 16:26:59 +0200 Subject: [PATCH 02/13] Fitbit Client added --- README.md | 17 ++++++ src/Client/Provider/FitbitClient.php | 34 ++++++++++++ .../KnpUOAuth2ClientExtension.php | 2 + .../Providers/FitbitProviderConfigurator.php | 54 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 src/Client/Provider/FitbitClient.php create mode 100644 src/DependencyInjection/Providers/FitbitProviderConfigurator.php diff --git a/README.md b/README.md index 093ea5a4..1d2150d5 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ via Composer: | [Dribbble](https://github.com/crewlabs/oauth2-dribbble) | composer require crewlabs/oauth2-dribbble | | [Dropbox](https://github.com/stevenmaguire/oauth2-dropbox) | composer require stevenmaguire/oauth2-dropbox | | [Drupal](https://github.com/chrishemmings/oauth2-drupal) | composer require chrishemmings/oauth2-drupal | +| [Fitbit](https://github.com/djchen/oauth2-fitbit) | composer require djchen/oauth2-fitbit | | [Eve Online](https://github.com/evelabs/oauth2-eveonline) | composer require evelabs/oauth2-eveonline | | [Facebook](https://github.com/thephpleague/oauth2-facebook) | composer require league/oauth2-facebook | | [HeadHunter](https://github.com/AlexMasterov/oauth2-headhunter) | composer require alexmasterov/oauth2-headhunter | @@ -455,6 +456,22 @@ knpu_oauth2_client: # whether to check OAuth2 "state": defaults to true # use_state: true + # will create service: "knpu.oauth2.client.fitbit" + # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\FitbitClient + # composer require djchen/oauth2-fitbit + fitbit: + # must be "fitbit" - it activates that type! + type: fitbit + # add and configure client_id and client_secret in parameters.yml + client_id: %fitbit_client_id% + client_secret: %fitbit_client_secret% + # a route name you'll create + redirect_route: connect_fitbit_check + redirect_params: {} + + # whether to check OAuth2 "state": defaults to true + # use_state: true + # will create service: "knpu.oauth2.client.eve_online" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\EveOnlineClient # composer require evelabs/oauth2-eveonline diff --git a/src/Client/Provider/FitbitClient.php b/src/Client/Provider/FitbitClient.php new file mode 100644 index 00000000..f71d37a8 --- /dev/null +++ b/src/Client/Provider/FitbitClient.php @@ -0,0 +1,34 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace KnpU\OAuth2ClientBundle\Client\Provider; + +use KnpU\OAuth2ClientBundle\Client\OAuth2Client; +use League\OAuth2\Client\Token\AccessToken; +use djchen\OAuth2\Client\Provider\FitbitUser; + +class FitbitClient extends OAuth2Client +{ + /** + * @param AccessToken $accessToken + * @return AmazonResourceOwner + */ + public function fetchUserFromToken(AccessToken $accessToken) + { + return parent::fetchUserFromToken($accessToken); + } + + /** + * @return FitbitUser + */ + public function fetchUser() + { + return parent::fetchUser(); + } +} \ No newline at end of file diff --git a/src/DependencyInjection/KnpUOAuth2ClientExtension.php b/src/DependencyInjection/KnpUOAuth2ClientExtension.php index 9e9c9b12..fb284def 100644 --- a/src/DependencyInjection/KnpUOAuth2ClientExtension.php +++ b/src/DependencyInjection/KnpUOAuth2ClientExtension.php @@ -20,6 +20,7 @@ use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\DrupalProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\EveOnlineProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\FacebookProviderConfigurator; +use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\FitbitProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\GenericProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\GithubProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\GitlabProviderConfigurator; @@ -67,6 +68,7 @@ class KnpUOAuth2ClientExtension extends Extension 'dribbble' => DribbbleProviderConfigurator::class, 'dropbox' => DropboxProviderConfigurator::class, 'drupal' => DrupalProviderConfigurator::class, + 'fitbit' => FitbitProviderConfigurator::class, 'eve_online' => EveOnlineProviderConfigurator::class, 'facebook' => FacebookProviderConfigurator::class, 'headhunter' => HeadHunterProviderConfigurator::class, diff --git a/src/DependencyInjection/Providers/FitbitProviderConfigurator.php b/src/DependencyInjection/Providers/FitbitProviderConfigurator.php new file mode 100644 index 00000000..10251188 --- /dev/null +++ b/src/DependencyInjection/Providers/FitbitProviderConfigurator.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace KnpU\OAuth2ClientBundle\DependencyInjection\Providers; + +use Symfony\Component\Config\Definition\Builder\NodeBuilder; + +class FitbitProviderConfigurator implements ProviderConfiguratorInterface +{ + public function buildConfiguration(NodeBuilder $node) + { + // no custom options + } + + public function getProviderClass(array $config) + { + return 'djchen\OAuth2\Client\Provider\Fitbit'; + } + + public function getProviderOptions(array $config) + { + return [ + 'clientId' => $config['client_id'], + 'clientSecret' => $config['client_secret'], + ]; + } + + public function getPackagistName() + { + return 'djchen/oauth2-fitbit'; + } + + public function getLibraryHomepage() + { + return 'https://github.com/djchen/oauth2-fitbit'; + } + + public function getProviderDisplayName() + { + return 'Fitbit'; + } + + public function getClientClass(array $config) + { + return 'KnpU\OAuth2ClientBundle\Client\Provider\FitbitClient'; + } +} \ No newline at end of file From bdd2a3bd1313c02bde8c999a6cc42da58e005794 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Sat, 7 Oct 2017 16:28:30 +0200 Subject: [PATCH 03/13] phpdoc declaration fix --- src/Client/Provider/FitbitClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/Provider/FitbitClient.php b/src/Client/Provider/FitbitClient.php index f71d37a8..0761a92c 100644 --- a/src/Client/Provider/FitbitClient.php +++ b/src/Client/Provider/FitbitClient.php @@ -17,7 +17,7 @@ class FitbitClient extends OAuth2Client { /** * @param AccessToken $accessToken - * @return AmazonResourceOwner + * @return FitbitUser */ public function fetchUserFromToken(AccessToken $accessToken) { From cb9b4020906d52f75941c54d0067684a6734bf15 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Sat, 7 Oct 2017 16:31:55 +0200 Subject: [PATCH 04/13] Heroku Client added --- README.md | 51 ++++++++++++------- src/Client/Provider/HerokuClient.php | 34 +++++++++++++ .../KnpUOAuth2ClientExtension.php | 4 +- 3 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 src/Client/Provider/HerokuClient.php diff --git a/README.md b/README.md index 1d2150d5..6bdcac5c 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,11 @@ via Composer: | [Dribbble](https://github.com/crewlabs/oauth2-dribbble) | composer require crewlabs/oauth2-dribbble | | [Dropbox](https://github.com/stevenmaguire/oauth2-dropbox) | composer require stevenmaguire/oauth2-dropbox | | [Drupal](https://github.com/chrishemmings/oauth2-drupal) | composer require chrishemmings/oauth2-drupal | -| [Fitbit](https://github.com/djchen/oauth2-fitbit) | composer require djchen/oauth2-fitbit | | [Eve Online](https://github.com/evelabs/oauth2-eveonline) | composer require evelabs/oauth2-eveonline | | [Facebook](https://github.com/thephpleague/oauth2-facebook) | composer require league/oauth2-facebook | +| [Fitbit](https://github.com/djchen/oauth2-fitbit) | composer require djchen/oauth2-fitbit | | [HeadHunter](https://github.com/AlexMasterov/oauth2-headhunter) | composer require alexmasterov/oauth2-headhunter | +| [Heroku](https://github.com/stevenmaguire/oauth2-heroku) | composer require stevenmaguire/oauth2-heroku | | [Instagram](https://github.com/thephpleague/oauth2-instagram) | composer require league/oauth2-instagram | | [GitHub](https://github.com/thephpleague/oauth2-github) | composer require league/oauth2-github | | [GitLab](https://github.com/omines/oauth2-gitlab) | composer require omines/oauth2-gitlab | @@ -456,22 +457,6 @@ knpu_oauth2_client: # whether to check OAuth2 "state": defaults to true # use_state: true - # will create service: "knpu.oauth2.client.fitbit" - # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\FitbitClient - # composer require djchen/oauth2-fitbit - fitbit: - # must be "fitbit" - it activates that type! - type: fitbit - # add and configure client_id and client_secret in parameters.yml - client_id: %fitbit_client_id% - client_secret: %fitbit_client_secret% - # a route name you'll create - redirect_route: connect_fitbit_check - redirect_params: {} - - # whether to check OAuth2 "state": defaults to true - # use_state: true - # will create service: "knpu.oauth2.client.eve_online" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\EveOnlineClient # composer require evelabs/oauth2-eveonline @@ -504,6 +489,22 @@ knpu_oauth2_client: # whether to check OAuth2 "state": defaults to true # use_state: true + # will create service: "knpu.oauth2.client.fitbit" + # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\FitbitClient + # composer require djchen/oauth2-fitbit + fitbit: + # must be "fitbit" - it activates that type! + type: fitbit + # add and configure client_id and client_secret in parameters.yml + client_id: %fitbit_client_id% + client_secret: %fitbit_client_secret% + # a route name you'll create + redirect_route: connect_fitbit_check + redirect_params: {} + + # whether to check OAuth2 "state": defaults to true + # use_state: true + # will create service: "knpu.oauth2.client.headhunter" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\HeadHunterClient # composer require alexmasterov/oauth2-headhunter @@ -520,6 +521,22 @@ knpu_oauth2_client: # whether to check OAuth2 "state": defaults to true # use_state: true + # will create service: "knpu.oauth2.client.heroku" + # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\HerokuClient + # composer require stevenmaguire/oauth2-heroku + heroku: + # must be "heroku" - it activates that type! + type: heroku + # add and configure client_id and client_secret in parameters.yml + client_id: %heroku_client_id% + client_secret: %heroku_client_secret% + # a route name you'll create + redirect_route: connect_heroku_check + redirect_params: {} + + # whether to check OAuth2 "state": defaults to true + # use_state: true + # will create service: "knpu.oauth2.client.instagram" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\InstagramClient # composer require league/oauth2-instagram diff --git a/src/Client/Provider/HerokuClient.php b/src/Client/Provider/HerokuClient.php new file mode 100644 index 00000000..5a435d17 --- /dev/null +++ b/src/Client/Provider/HerokuClient.php @@ -0,0 +1,34 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace KnpU\OAuth2ClientBundle\Client\Provider; + +use KnpU\OAuth2ClientBundle\Client\OAuth2Client; +use League\OAuth2\Client\Token\AccessToken; +use Stevenmaguire\OAuth2\Client\Provider\HerokuResourceOwner; + +class HerokuClient extends OAuth2Client +{ + /** + * @param AccessToken $accessToken + * @return HerokuResourceOwner + */ + public function fetchUserFromToken(AccessToken $accessToken) + { + return parent::fetchUserFromToken($accessToken); + } + + /** + * @return HerokuResourceOwner + */ + public function fetchUser() + { + return parent::fetchUser(); + } +} \ No newline at end of file diff --git a/src/DependencyInjection/KnpUOAuth2ClientExtension.php b/src/DependencyInjection/KnpUOAuth2ClientExtension.php index fb284def..6abb538f 100644 --- a/src/DependencyInjection/KnpUOAuth2ClientExtension.php +++ b/src/DependencyInjection/KnpUOAuth2ClientExtension.php @@ -26,6 +26,7 @@ use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\GitlabProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\GoogleProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\HeadHunterProviderConfigurator; +use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\HerokuProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\InstagramProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\LinkedInProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\MicrosoftProviderConfigurator; @@ -68,10 +69,11 @@ class KnpUOAuth2ClientExtension extends Extension 'dribbble' => DribbbleProviderConfigurator::class, 'dropbox' => DropboxProviderConfigurator::class, 'drupal' => DrupalProviderConfigurator::class, - 'fitbit' => FitbitProviderConfigurator::class, 'eve_online' => EveOnlineProviderConfigurator::class, 'facebook' => FacebookProviderConfigurator::class, + 'fitbit' => FitbitProviderConfigurator::class, 'headhunter' => HeadHunterProviderConfigurator::class, + 'heroku' => HerokuProviderConfigurator::class, 'instagram' => InstagramProviderConfigurator::class, 'github' => GithubProviderConfigurator::class, 'gitlab' => GitlabProviderConfigurator::class, From 1bc1c7079953abbf2b32e0dd907f39c6505b0abb Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Sat, 7 Oct 2017 16:32:49 +0200 Subject: [PATCH 05/13] Heroku Configurator added --- .../Providers/HerokuProviderConfigurator.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/DependencyInjection/Providers/HerokuProviderConfigurator.php diff --git a/src/DependencyInjection/Providers/HerokuProviderConfigurator.php b/src/DependencyInjection/Providers/HerokuProviderConfigurator.php new file mode 100644 index 00000000..69f7e94a --- /dev/null +++ b/src/DependencyInjection/Providers/HerokuProviderConfigurator.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace KnpU\OAuth2ClientBundle\DependencyInjection\Providers; + +use Symfony\Component\Config\Definition\Builder\NodeBuilder; + +class HerokuProviderConfigurator implements ProviderConfiguratorInterface +{ + public function buildConfiguration(NodeBuilder $node) + { + // no custom options + } + + public function getProviderClass(array $config) + { + return 'Stevenmaguire\OAuth2\Client\Provider\Heroku'; + } + + public function getProviderOptions(array $config) + { + return [ + 'clientId' => $config['client_id'], + 'clientSecret' => $config['client_secret'], + ]; + } + + public function getPackagistName() + { + return 'stevenmaguire/oauth2-heroku'; + } + + public function getLibraryHomepage() + { + return 'https://github.com/stevenmaguire/oauth2-heroku'; + } + + public function getProviderDisplayName() + { + return 'Heroku'; + } + + public function getClientClass(array $config) + { + return 'KnpU\OAuth2ClientBundle\Client\Provider\HerokuClient'; + } +} \ No newline at end of file From 31d0e21de5d8b04faae12df9017e3a00e62d9a16 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Sat, 7 Oct 2017 16:39:17 +0200 Subject: [PATCH 06/13] Paypal Configurator added --- README.md | 18 ++++++ src/Client/Provider/PaypalClient.php | 34 +++++++++++ .../KnpUOAuth2ClientExtension.php | 2 + .../Providers/PaypalProviderConfigurator.php | 60 +++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 src/Client/Provider/PaypalClient.php create mode 100644 src/DependencyInjection/Providers/PaypalProviderConfigurator.php diff --git a/README.md b/README.md index 6bdcac5c..c891c47f 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ via Composer: | [LinkedIn](https://github.com/thephpleague/oauth2-linkedin) | composer require league/oauth2-linkedin | | [Microsoft](https://github.com/stevenmaguire/oauth2-microsoft) | composer require stevenmaguire/oauth2-microsoft | | [Odnoklassniki](https://github.com/rakeev/oauth2-odnoklassniki) | composer require aego/oauth2-odnoklassniki | +| [Paypal](https://github.com/stevenmaguire/oauth2-paypal) | composer require stevenmaguire/oauth2-paypal | | [Slack](https://github.com/adam-paterson/oauth2-slack) | composer require adam-paterson/oauth2-slack | | [Vimeo](https://github.com/saf33r/oauth2-vimeo) | composer require saf33r/oauth2-vimeo | | [VKontakte](https://github.com/j4k/oauth2-vkontakte) | composer require j4k/oauth2-vkontakte | @@ -660,6 +661,23 @@ knpu_oauth2_client: # whether to check OAuth2 "state": defaults to true # use_state: true + # will create service: "knpu.oauth2.client.paypal" + # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\PaypalClient + # composer require stevenmaguire/oauth2-paypal + paypal: + # must be "paypal" - it activates that type! + type: paypal + # add and configure client_id and client_secret in parameters.yml + client_id: %paypal_client_id% + client_secret: %paypal_client_secret% + # a route name you'll create + redirect_route: connect_paypal_check + redirect_params: {} + # When true, client uses Paypal Sandbox urls. + # is_sandbox: '' + # whether to check OAuth2 "state": defaults to true + # use_state: true + # will create service: "knpu.oauth2.client.slack" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\SlackClient # composer require adam-paterson/oauth2-slack diff --git a/src/Client/Provider/PaypalClient.php b/src/Client/Provider/PaypalClient.php new file mode 100644 index 00000000..37afc9b5 --- /dev/null +++ b/src/Client/Provider/PaypalClient.php @@ -0,0 +1,34 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace KnpU\OAuth2ClientBundle\Client\Provider; + +use KnpU\OAuth2ClientBundle\Client\OAuth2Client; +use League\OAuth2\Client\Token\AccessToken; +use Stevenmaguire\OAuth2\Client\Provider\PaypalResourceOwner; + +class PaypalClient extends OAuth2Client +{ + /** + * @param AccessToken $accessToken + * @return PaypalResourceOwner + */ + public function fetchUserFromToken(AccessToken $accessToken) + { + return parent::fetchUserFromToken($accessToken); + } + + /** + * @return PaypalResourceOwner + */ + public function fetchUser() + { + return parent::fetchUser(); + } +} \ No newline at end of file diff --git a/src/DependencyInjection/KnpUOAuth2ClientExtension.php b/src/DependencyInjection/KnpUOAuth2ClientExtension.php index 6abb538f..8cc8106d 100644 --- a/src/DependencyInjection/KnpUOAuth2ClientExtension.php +++ b/src/DependencyInjection/KnpUOAuth2ClientExtension.php @@ -31,6 +31,7 @@ use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\LinkedInProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\MicrosoftProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\OdnoklassnikiProviderConfigurator; +use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\PaypalProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\ProviderConfiguratorInterface; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\SlackProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\VimeoProviderConfigurator; @@ -81,6 +82,7 @@ class KnpUOAuth2ClientExtension extends Extension 'linkedin' => LinkedInProviderConfigurator::class, 'microsoft' => MicrosoftProviderConfigurator::class, 'odnoklassniki' => OdnoklassnikiProviderConfigurator::class, + 'paypal' => PaypalProviderConfigurator::class, 'slack' => SlackProviderConfigurator::class, 'vimeo' => VimeoProviderConfigurator::class, 'vkontakte' => VKontakteProviderConfigurator::class, diff --git a/src/DependencyInjection/Providers/PaypalProviderConfigurator.php b/src/DependencyInjection/Providers/PaypalProviderConfigurator.php new file mode 100644 index 00000000..c2a4b93d --- /dev/null +++ b/src/DependencyInjection/Providers/PaypalProviderConfigurator.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace KnpU\OAuth2ClientBundle\DependencyInjection\Providers; + +use Symfony\Component\Config\Definition\Builder\NodeBuilder; + +class PaypalProviderConfigurator implements ProviderConfiguratorInterface +{ + public function buildConfiguration(NodeBuilder $node) + { + $node + ->scalarNode('is_sandbox') + ->defaultFalse() + ->info('When true, client uses Paypal Sandbox urls.') + ->end() + ; + } + + public function getProviderClass(array $config) + { + return 'Stevenmaguire\OAuth2\Client\Provider\Paypal'; + } + + public function getProviderOptions(array $config) + { + return [ + 'clientId' => $config['client_id'], + 'clientSecret' => $config['client_secret'], + 'isSandbox' => $config['is_sandbox'], + ]; + } + + public function getPackagistName() + { + return 'stevenmaguire/oauth2-paypal'; + } + + public function getLibraryHomepage() + { + return 'https://github.com/stevenmaguire/oauth2-paypal'; + } + + public function getProviderDisplayName() + { + return 'Paypal'; + } + + public function getClientClass(array $config) + { + return 'KnpU\OAuth2ClientBundle\Client\Provider\PaypalClient'; + } +} \ No newline at end of file From 8d7fbce07a33aef8a663e289383fc4f41fded56f Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Sat, 7 Oct 2017 16:45:19 +0200 Subject: [PATCH 07/13] Stripe Client added --- README.md | 17 ++++++ src/Client/Provider/StripeClient.php | 34 ++++++++++++ .../KnpUOAuth2ClientExtension.php | 2 + .../Providers/StripeProviderConfigurator.php | 54 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 src/Client/Provider/StripeClient.php create mode 100644 src/DependencyInjection/Providers/StripeProviderConfigurator.php diff --git a/README.md b/README.md index c891c47f..594f661c 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ via Composer: | [Odnoklassniki](https://github.com/rakeev/oauth2-odnoklassniki) | composer require aego/oauth2-odnoklassniki | | [Paypal](https://github.com/stevenmaguire/oauth2-paypal) | composer require stevenmaguire/oauth2-paypal | | [Slack](https://github.com/adam-paterson/oauth2-slack) | composer require adam-paterson/oauth2-slack | +| [Stripe](https://github.com/adam-paterson/oauth2-stripe) | composer require adam-paterson/oauth2-stripe | | [Vimeo](https://github.com/saf33r/oauth2-vimeo) | composer require saf33r/oauth2-vimeo | | [VKontakte](https://github.com/j4k/oauth2-vkontakte) | composer require j4k/oauth2-vkontakte | | [Yahoo](https://github.com/hayageek/oauth2-yahoo) | composer require hayageek/oauth2-yahoo | @@ -694,6 +695,22 @@ knpu_oauth2_client: # whether to check OAuth2 "state": defaults to true # use_state: true + # will create service: "knpu.oauth2.client.stripe" + # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\StripeClient + # composer require adam-paterson/oauth2-stripe + stripe: + # must be "stripe" - it activates that type! + type: stripe + # add and configure client_id and client_secret in parameters.yml + client_id: %stripe_client_id% + client_secret: %stripe_client_secret% + # a route name you'll create + redirect_route: connect_stripe_check + redirect_params: {} + + # whether to check OAuth2 "state": defaults to true + # use_state: true + # will create service: "knpu.oauth2.client.vimeo" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\VimeoClient # composer require saf33r/oauth2-vimeo diff --git a/src/Client/Provider/StripeClient.php b/src/Client/Provider/StripeClient.php new file mode 100644 index 00000000..6eb9be97 --- /dev/null +++ b/src/Client/Provider/StripeClient.php @@ -0,0 +1,34 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace KnpU\OAuth2ClientBundle\Client\Provider; + +use KnpU\OAuth2ClientBundle\Client\OAuth2Client; +use League\OAuth2\Client\Token\AccessToken; +use AdamPaterson\OAuth2\Client\Provider\StripeResourceOwner; + +class StripeClient extends OAuth2Client +{ + /** + * @param AccessToken $accessToken + * @return StripeResourceOwner + */ + public function fetchUserFromToken(AccessToken $accessToken) + { + return parent::fetchUserFromToken($accessToken); + } + + /** + * @return StripeResourceOwner + */ + public function fetchUser() + { + return parent::fetchUser(); + } +} \ No newline at end of file diff --git a/src/DependencyInjection/KnpUOAuth2ClientExtension.php b/src/DependencyInjection/KnpUOAuth2ClientExtension.php index 8cc8106d..76c81404 100644 --- a/src/DependencyInjection/KnpUOAuth2ClientExtension.php +++ b/src/DependencyInjection/KnpUOAuth2ClientExtension.php @@ -34,6 +34,7 @@ use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\PaypalProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\ProviderConfiguratorInterface; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\SlackProviderConfigurator; +use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\StripeProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\VimeoProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\VKontakteProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\YahooProviderConfigurator; @@ -84,6 +85,7 @@ class KnpUOAuth2ClientExtension extends Extension 'odnoklassniki' => OdnoklassnikiProviderConfigurator::class, 'paypal' => PaypalProviderConfigurator::class, 'slack' => SlackProviderConfigurator::class, + 'stripe' => StripeProviderConfigurator::class, 'vimeo' => VimeoProviderConfigurator::class, 'vkontakte' => VKontakteProviderConfigurator::class, 'yahoo' => YahooProviderConfigurator::class, diff --git a/src/DependencyInjection/Providers/StripeProviderConfigurator.php b/src/DependencyInjection/Providers/StripeProviderConfigurator.php new file mode 100644 index 00000000..05f922a6 --- /dev/null +++ b/src/DependencyInjection/Providers/StripeProviderConfigurator.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace KnpU\OAuth2ClientBundle\DependencyInjection\Providers; + +use Symfony\Component\Config\Definition\Builder\NodeBuilder; + +class StripeProviderConfigurator implements ProviderConfiguratorInterface +{ + public function buildConfiguration(NodeBuilder $node) + { + // no custom options + } + + public function getProviderClass(array $config) + { + return '\AdamPaterson\OAuth2\Client\Provider\Stripe'; + } + + public function getProviderOptions(array $config) + { + return [ + 'clientId' => $config['client_id'], + 'clientSecret' => $config['client_secret'], + ]; + } + + public function getPackagistName() + { + return 'adam-paterson/oauth2-stripe'; + } + + public function getLibraryHomepage() + { + return 'https://github.com/adam-paterson/oauth2-stripe'; + } + + public function getProviderDisplayName() + { + return 'Stripe'; + } + + public function getClientClass(array $config) + { + return 'KnpU\OAuth2ClientBundle\Client\Provider\StripeClient'; + } +} \ No newline at end of file From 69b75aed290ce42747132b5df9c87cabe3889ff7 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Fri, 20 Oct 2017 09:11:56 +0200 Subject: [PATCH 08/13] Stripe Provider Class updated --- .../Providers/StripeProviderConfigurator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DependencyInjection/Providers/StripeProviderConfigurator.php b/src/DependencyInjection/Providers/StripeProviderConfigurator.php index 05f922a6..2ae06bf6 100644 --- a/src/DependencyInjection/Providers/StripeProviderConfigurator.php +++ b/src/DependencyInjection/Providers/StripeProviderConfigurator.php @@ -21,7 +21,7 @@ public function buildConfiguration(NodeBuilder $node) public function getProviderClass(array $config) { - return '\AdamPaterson\OAuth2\Client\Provider\Stripe'; + return 'AdamPaterson\OAuth2\Client\Provider\Stripe'; } public function getProviderOptions(array $config) From c546f68b47f7c78fede08285ba2a92ea480fd5e6 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Fri, 20 Oct 2017 09:16:08 +0200 Subject: [PATCH 09/13] Paypal Configurator updated --- .../Providers/PaypalProviderConfigurator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Providers/PaypalProviderConfigurator.php b/src/DependencyInjection/Providers/PaypalProviderConfigurator.php index c2a4b93d..8b212ca2 100644 --- a/src/DependencyInjection/Providers/PaypalProviderConfigurator.php +++ b/src/DependencyInjection/Providers/PaypalProviderConfigurator.php @@ -17,9 +17,9 @@ class PaypalProviderConfigurator implements ProviderConfiguratorInterface public function buildConfiguration(NodeBuilder $node) { $node - ->scalarNode('is_sandbox') + ->booleanNode('is_sandbox') ->defaultFalse() - ->info('When true, client uses Paypal Sandbox urls.') + ->info('When true, client uses Paypal Sandbox URLs.') ->end() ; } From 02498985a016f9715f9d9387f2ad91ec71719a02 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Fri, 20 Oct 2017 09:17:07 +0200 Subject: [PATCH 10/13] Readme updated --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 594f661c..f6699c24 100644 --- a/README.md +++ b/README.md @@ -674,8 +674,8 @@ knpu_oauth2_client: # a route name you'll create redirect_route: connect_paypal_check redirect_params: {} - # When true, client uses Paypal Sandbox urls. - # is_sandbox: '' + # When true, client uses Paypal Sandbox URLs. + # is_sandbox: false # whether to check OAuth2 "state": defaults to true # use_state: true From 1c76779154e3910a04c598b7c64dccc633339f38 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Fri, 20 Oct 2017 09:28:09 +0200 Subject: [PATCH 11/13] Unit Test Data Provider updated to accept boolean values --- tests/DependencyInjection/KnpUOAuth2ClientExtensionTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/DependencyInjection/KnpUOAuth2ClientExtensionTest.php b/tests/DependencyInjection/KnpUOAuth2ClientExtensionTest.php index 48a2d05a..d5961737 100644 --- a/tests/DependencyInjection/KnpUOAuth2ClientExtensionTest.php +++ b/tests/DependencyInjection/KnpUOAuth2ClientExtensionTest.php @@ -13,6 +13,7 @@ use KnpU\OAuth2ClientBundle\DependencyInjection\KnpUOAuth2ClientExtension; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\ProviderConfiguratorInterface; use Symfony\Component\Config\Definition\ArrayNode; +use Symfony\Component\Config\Definition\BooleanNode; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -151,6 +152,8 @@ public function provideTypesAndConfig() /** @var NodeInterface $child */ if ($child instanceof ArrayNode) { $config[$child->getName()] = []; + } elseif ($child instanceof BooleanNode) { + $config[$child->getName()] = (bool) rand(0, 1); } else { $config[$child->getName()] = rand(); } From e9c31ab9ddcfc8dfa95ed9d8c3e3baf6d4018579 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Fri, 20 Oct 2017 09:35:15 +0200 Subject: [PATCH 12/13] update_readme is updated to set boolean values --- bin/update_readme | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/update_readme b/bin/update_readme index 970bfeb2..2aaf3a18 100755 --- a/bin/update_readme +++ b/bin/update_readme @@ -11,6 +11,7 @@ require __DIR__.'/../vendor/autoload.php'; use KnpU\OAuth2ClientBundle\DependencyInjection\KnpUOAuth2ClientExtension; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ArrayNode; +use Symfony\Component\Config\Definition\BooleanNode; use Symfony\Component\Config\Definition\NodeInterface; function replaceInString($startTextMarker, $endTextMarker, $fullText, $replacementText) @@ -92,6 +93,11 @@ foreach (KnpUOAuth2ClientExtension::getAllSupportedTypes() as $type) { // *should* ? come out looking like valid-ish YAML ? json_encode($child->getDefaultValue()) : '{}'; + + } elseif ($child instanceof BooleanNode) { + $defaultValue = $child->getDefaultValue() + ? $child->getDefaultValue() + : 'false'; } else { $defaultValue = $child->getDefaultValue() ? $child->getDefaultValue() From 365878e0098575f17c98c902c26521a1c68bb465 Mon Sep 17 00:00:00 2001 From: Serghei Luchianenco Date: Fri, 20 Oct 2017 09:57:10 +0200 Subject: [PATCH 13/13] update_readme is updated to use true/false string values in boolean nodes --- bin/update_readme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/update_readme b/bin/update_readme index 2aaf3a18..79483851 100755 --- a/bin/update_readme +++ b/bin/update_readme @@ -96,7 +96,7 @@ foreach (KnpUOAuth2ClientExtension::getAllSupportedTypes() as $type) { } elseif ($child instanceof BooleanNode) { $defaultValue = $child->getDefaultValue() - ? $child->getDefaultValue() + ? 'true' : 'false'; } else { $defaultValue = $child->getDefaultValue()