-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from akondas/buddy-works
Add Buddy client
- Loading branch information
Showing
6 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?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 Buddy\OAuth2\Client\Provider\BuddyResourceOwner; | ||
use KnpU\OAuth2ClientBundle\Client\OAuth2Client; | ||
use League\OAuth2\Client\Provider\ResourceOwnerInterface; | ||
use League\OAuth2\Client\Token\AccessToken; | ||
|
||
class BuddyClient extends OAuth2Client | ||
{ | ||
/** | ||
* @return BuddyResourceOwner|ResourceOwnerInterface | ||
*/ | ||
public function fetchUserFromToken(AccessToken $accessToken) | ||
{ | ||
return parent::fetchUserFromToken($accessToken); | ||
} | ||
|
||
/** | ||
* @return BuddyResourceOwner|ResourceOwnerInterface | ||
*/ | ||
public function fetchUser() | ||
{ | ||
return parent::fetchUser(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/DependencyInjection/Providers/BuddyProviderConfigurator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?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 Symfony\Component\Config\Definition\Builder\NodeBuilder; | ||
|
||
class BuddyProviderConfigurator implements ProviderConfiguratorInterface | ||
{ | ||
public function buildConfiguration(NodeBuilder $node) | ||
{ | ||
$node | ||
->scalarNode('base_api_url') | ||
->info('Base API URL, modify this for self-hosted instances') | ||
->defaultValue('https://api.buddy.works') | ||
->cannotBeEmpty() | ||
->end(); | ||
} | ||
|
||
public function getProviderClass(array $config) | ||
{ | ||
return 'Buddy\OAuth2\Client\Provider\Buddy'; | ||
} | ||
|
||
public function getProviderOptions(array $config) | ||
{ | ||
return [ | ||
'clientId' => $config['client_id'], | ||
'clientSecret' => $config['client_secret'], | ||
'baseApiUrl' => $config['base_api_url'], | ||
]; | ||
} | ||
|
||
public function getPackagistName() | ||
{ | ||
return 'buddy-works/oauth2-client'; | ||
} | ||
|
||
public function getLibraryHomepage() | ||
{ | ||
return 'https://github.com/buddy-works/oauth2-client'; | ||
} | ||
|
||
public function getProviderDisplayName() | ||
{ | ||
return 'Buddy'; | ||
} | ||
|
||
public function getClientClass(array $config) | ||
{ | ||
return 'KnpU\OAuth2ClientBundle\Client\Provider\BuddyClient'; | ||
} | ||
} |