Closed cloudcogsio closed 1 year ago
Proposed
New AbstractOIDCProvider
that extends the base AbstractProvider
but provides mechanisms for OIDC.
Custom Providers wishing to utilize OIDC should extend the AbstractOIDCProvider
class.
An Interface which should be implemented and passed to the Provider config that will handle caching of public keys (JWKs). A simple file system implementation is provided. League\OAuth2\Client\Provider\OpenIDConnect\PublicKeyCache\File
Required configs are [clientId, clientSecret, well_known_endpoint, publickey_cache_provider]
League\OAuth2\Client\Provider\OpenIDConnect\PublicKeyCacheInterface
I believe backward compatibility is maintained with 2.x
use League\OAuth2\Client\Provider\OpenIDConnect\AbstractOIDCProvider;
class MyProvider extends AbstractOIDCProvider
{
/**
* {@inheritDoc}
* @see \League\OAuth2\Client\Provider\AbstractProvider::getDefaultScopes()
*/
protected function getDefaultScopes()
{
// TODO Auto-generated method stub
}
/**
* {@inheritDoc}
* @see \League\OAuth2\Client\Provider\AbstractProvider::checkResponse()
*/
protected function checkResponse(\Psr\Http\Message\ResponseInterface $response, $data)
{
// TODO Auto-generated method stub
}
/**
* {@inheritDoc}
* @see \League\OAuth2\Client\Provider\AbstractProvider::createResourceOwner()
*/
protected function createResourceOwner(array $response, \League\OAuth2\Client\Token\AccessToken $token)
{
// TODO Auto-generated method stub
}
}
$Provider = new MyProvider([
AbstractOIDCProvider::OPTION_WELL_KNOWN_URL => 'https://my.auth.server/.well-known/openid-configuration',
AbstractOIDCProvider::OPTION_PUBLICKEY_CACHE_PROVIDER => new \League\OAuth2\Client\Provider\OpenIDConnect\PublicKeyCache\File('my.auth.server.keys'),
'clientId' => '{CLIENT-ID}',
'clientSecret' => '{CLIENT-SECRET}'
]);
// Dump the auto discovered data
print_r($Provider->Discovery());
// Get the base auth URL
print $Provider->Discovery()->getAuthorizationEndpoint();
Thank you for this :)
Thank you for this :)
You're welcome.
Decided to make it available as a separate package. https://github.com/cloudcogsio/oauth2-openid-connect-discovery
May close this PR or leave pending for 3.x consideration.
Is there any plan merge this PR ? Thanks
Initial Commit Tests and Documentation to follow.