-
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 #268 from foxworth42/add-okta-client
Add Okta client
- Loading branch information
Showing
5 changed files
with
122 additions
and
0 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,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 Foxworth42\OAuth2\Client\Provider\OktaUser; | ||
use KnpU\OAuth2ClientBundle\Client\OAuth2Client; | ||
use League\OAuth2\Client\Token\AccessToken; | ||
|
||
class OktaClient extends OAuth2Client | ||
{ | ||
/** | ||
* @return OktaUser|\League\OAuth2\Client\Provider\ResourceOwnerInterface | ||
*/ | ||
public function fetchUserFromToken(AccessToken $accessToken) | ||
{ | ||
return parent::fetchUserFromToken($accessToken); | ||
} | ||
|
||
/** | ||
* @return OktaUser|\League\OAuth2\Client\Provider\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
65 changes: 65 additions & 0 deletions
65
src/DependencyInjection/Providers/OktaProviderConfigurator.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,65 @@ | ||
<?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 OktaProviderConfigurator implements ProviderConfiguratorInterface | ||
{ | ||
public function buildConfiguration(NodeBuilder $node) | ||
{ | ||
$node | ||
->scalarNode('issuer') | ||
->isRequired() | ||
->info('Issuer URI from Okta') | ||
->example('issuer: https://mycompany.okta.com/oauth2/default') | ||
->end(); | ||
} | ||
|
||
public function getProviderClass(array $config) | ||
{ | ||
return 'Foxworth42\OAuth2\Client\Provider\Okta'; | ||
} | ||
|
||
public function getProviderOptions(array $config) | ||
{ | ||
$options = [ | ||
'clientId' => $config['client_id'], | ||
'clientSecret' => $config['client_secret'], | ||
]; | ||
|
||
if ($config['issuer']) { | ||
$options['issuer'] = $config['issuer']; | ||
} | ||
|
||
return $options; | ||
} | ||
|
||
public function getPackagistName() | ||
{ | ||
return 'foxworth42/oauth2-okta'; | ||
} | ||
|
||
public function getLibraryHomepage() | ||
{ | ||
return 'https://github.com/foxworth42/oauth2-okta'; | ||
} | ||
|
||
public function getProviderDisplayName() | ||
{ | ||
return 'Okta'; | ||
} | ||
|
||
public function getClientClass(array $config) | ||
{ | ||
return 'KnpU\OAuth2ClientBundle\Client\Provider\OktaClient'; | ||
} | ||
} |