diff --git a/README.md b/README.md index 59eb7831..40bff508 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ via Composer: | [DevianArt](https://github.com/SeinopSys/oauth2-deviantart) | composer require seinopsys/oauth2-deviantart | | [DigitalOcean](https://github.com/chrishemmings/oauth2-digitalocean) | composer require chrishemmings/oauth2-digitalocean | | [Discord](https://github.com/wohali/oauth2-discord-new) | composer require wohali/oauth2-discord-new | +| [Disqus](https://github.com/antalaron/oauth2-disqus) | composer require antalaron/oauth2-disqus | | [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 | @@ -881,6 +882,21 @@ knpu_oauth2_client: # whether to check OAuth2 "state": defaults to true # use_state: true + # will create service: "knpu.oauth2.client.disqus" + # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\DisqusClient + # composer require antalaron/oauth2-disqus + disqus: + # must be "disqus" - it activates that type! + type: disqus + # add and set these environment variables in your .env files + client_id: '%env(OAUTH_DISQUS_CLIENT_ID)%' + client_secret: '%env(OAUTH_DISQUS_CLIENT_SECRET)%' + # a route name you'll create + redirect_route: connect_disqus_check + redirect_params: {} + # whether to check OAuth2 "state": defaults to true + # use_state: true + # will create service: "knpu.oauth2.client.dribbble" # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\DribbbleClient # composer require crewlabs/oauth2-dribbble diff --git a/src/Client/Provider/DisqusClient.php b/src/Client/Provider/DisqusClient.php new file mode 100644 index 00000000..d38f8ad4 --- /dev/null +++ b/src/Client/Provider/DisqusClient.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 Antalaron\DisqusOAuth2\DisqusResourceOwner; +use KnpU\OAuth2ClientBundle\Client\OAuth2Client; +use League\OAuth2\Client\Token\AccessToken; + +class DisqusClient extends OAuth2Client +{ + /** + * @return DisqusResourceOwner|\League\OAuth2\Client\Provider\ResourceOwnerInterface + */ + public function fetchUserFromToken(AccessToken $accessToken) + { + return parent::fetchUserFromToken($accessToken); + } + + /** + * @return DisqusResourceOwner|\League\OAuth2\Client\Provider\ResourceOwnerInterface + */ + public function fetchUser() + { + return parent::fetchUser(); + } +} diff --git a/src/DependencyInjection/KnpUOAuth2ClientExtension.php b/src/DependencyInjection/KnpUOAuth2ClientExtension.php index f5cf5748..daa5bcdb 100644 --- a/src/DependencyInjection/KnpUOAuth2ClientExtension.php +++ b/src/DependencyInjection/KnpUOAuth2ClientExtension.php @@ -24,6 +24,7 @@ use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\DevianArtProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\DigitalOceanProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\DiscordProviderConfigurator; +use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\DisqusProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\DribbbleProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\DropboxProviderConfigurator; use KnpU\OAuth2ClientBundle\DependencyInjection\Providers\DrupalProviderConfigurator; @@ -106,6 +107,7 @@ class KnpUOAuth2ClientExtension extends Extension 'devian_art' => DevianArtProviderConfigurator::class, 'digital_ocean' => DigitalOceanProviderConfigurator::class, 'discord' => DiscordProviderConfigurator::class, + 'disqus' => DisqusProviderConfigurator::class, 'dribbble' => DribbbleProviderConfigurator::class, 'dropbox' => DropboxProviderConfigurator::class, 'drupal' => DrupalProviderConfigurator::class, diff --git a/src/DependencyInjection/Providers/DisqusProviderConfigurator.php b/src/DependencyInjection/Providers/DisqusProviderConfigurator.php new file mode 100644 index 00000000..af710d80 --- /dev/null +++ b/src/DependencyInjection/Providers/DisqusProviderConfigurator.php @@ -0,0 +1,55 @@ + + * + * 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 KnpU\OAuth2ClientBundle\Client\Provider\DisqusClient; +use Symfony\Component\Config\Definition\Builder\NodeBuilder; + +class DisqusProviderConfigurator implements ProviderConfiguratorInterface +{ + public function buildConfiguration(NodeBuilder $node) + { + // no custom options + } + + public function getProviderClass(array $config) + { + return 'Antalaron\DisqusOAuth2\Disqus'; + } + + public function getProviderOptions(array $config) + { + return [ + 'clientId' => $config['client_id'], + 'clientSecret' => $config['client_secret'], + ]; + } + + public function getPackagistName() + { + return 'antalaron/oauth2-disqus'; + } + + public function getLibraryHomepage() + { + return 'https://github.com/antalaron/oauth2-disqus'; + } + + public function getProviderDisplayName() + { + return 'Disqus'; + } + + public function getClientClass(array $config) + { + return DisqusClient::class; + } +}