Auth0\SDK\JWTVerifier::__construct PHP Метод

__construct() публичный Метод

Configuration: - cache (CacheHandler) Optional. Should be an instance of CacheHandler that is going to be used to cache the JWKs - suported_algs (Array) Optional. The list of supported algorithms. By default only HS256 - client_secret (String) Required (if supported HS256). The Auth0 application secret. - valid_audiences (Array) Required. The list of audiences accepted by the service. - authorized_iss (Array) Required (if supported RS256). The list of issuers trusted by the service. - guzzle_options (Array) Optional Extra configuration options sent to guzzle.
public __construct ( $config )
    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);
    }