Skip to content

Commit

Permalink
Add Disqus provider
Browse files Browse the repository at this point in the history
  • Loading branch information
antalaron committed May 3, 2023
1 parent 4521968 commit 2a9fb30
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions src/Client/Provider/DisqusClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* OAuth2 Client Bundle
* Copyright (c) KnpUniversity <http://knpuniversity.com/>
*
* 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();
}
}
2 changes: 2 additions & 0 deletions src/DependencyInjection/KnpUOAuth2ClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
55 changes: 55 additions & 0 deletions src/DependencyInjection/Providers/DisqusProviderConfigurator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
* OAuth2 Client Bundle
* Copyright (c) KnpUniversity <http://knpuniversity.com/>
*
* 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;
}
}

0 comments on commit 2a9fb30

Please sign in to comment.