digitalcz/oidc-discovery

PHP implementation of https://openid.net/specs/openid-connect-discovery-1_0.html


README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require CI Scrutinizer Code Quality codecov

PHP implementation of https://openid.net/specs/openid-connect-discovery-1_0.html

Install

Via Composer

$ composer require digitalcz/oidc-discovery

Usage

If php-http/discovery package is present, DiscoveryFactory will use it to find PSR18 client and PSR17 factory.

use DigitalCz\OpenIDConnect\Discovery\DiscovererFactory;

$discoverer = DiscovererFactory::create()
$providerMetadata = $discoverer->discover('https://accounts.google.com/.well-known/openid-configuration');
$issuer = $providerMetadata->issuer(); // https://accounts.google.com
$tokenEndpoint = $providerMetadata->tokenEndpoint(); // https://oauth2.googleapis.com/token

otherwise, you can provide these manually

use DigitalCz\OpenIDConnect\Discovery\DiscovererFactory;
use Http\Client\Curl\Client;
use Nyholm\Psr7\Factory\Psr17Factory;

$client = new Client();
$requestFactory = new Psr17Factory();
$discoverer = DiscovererFactory::create($client, $requestFactory);

Add cache to avoid unnecessary calls

use DigitalCz\OpenIDConnect\Discovery\DiscovererFactory;
use Symfony\Component\Cache\Adapter\FilesystemAdapter
use Symfony\Component\Cache\Psr16Cache;

$cache = new Psr16Cache(new FilesystemAdapter())
$discoverer = DiscovererFactory::create(cache: $cache, cacheTtl: 1800);

See examples for more

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer csfix    # fix codestyle
$ composer checks   # run all checks 

# or separately
$ composer tests    # run phpunit
$ composer phpstan  # run phpstan
$ composer cs       # run codesniffer

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email devs@digital.cz instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.