public function __construct($config)
{
$cache = null;
$guzzleOptions = [];
if (isset($config['cache'])) {
$cache = $config['cache'];
}
if (isset($config['guzzle_options'])) {
$guzzleOptions = $config['guzzle_options'];
}
if (!isset($config['suported_algs'])) {
$config['suported_algs'] = ['HS256'];
}
if (!isset($config['secret_base64_encoded'])) {
$config['secret_base64_encoded'] = true;
}
if (!isset($config['valid_audiences'])) {
throw new CoreException('The audience is mandatory');
}
if (!isset($config['authorized_iss'])) {
if (in_array('RS256', $config['suported_algs'])) {
throw new CoreException('The iss is mandatory when accepting RS256 signed tokens');
} else {
$config['authorized_iss'] = [];
}
}
if (in_array('HS256', $config['suported_algs']) && !isset($config['client_secret'])) {
throw new CoreException('The client_secret is mandatory when accepting HS256 signed tokens');
}
$this->suported_algs = $config['suported_algs'];
$this->valid_audiences = $config['valid_audiences'];
$this->authorized_iss = $config['authorized_iss'];
$this->secret_base64_encoded = $config['secret_base64_encoded'];
if (in_array('HS256', $config['suported_algs'])) {
$this->client_secret = $config['client_secret'];
}
$this->JWKFetcher = new JWKFetcher($cache, $guzzleOptions);
}