<commit_before><?php

/*
 * This file is part of the HWIOAuthBundle package.
 *
 * (c) Hardware.Info <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace HWI\Bundle\OAuthBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * Configuration for the extension.
 *
 * @author Alexander <<EMAIL>>
 */
class Configuration implements ConfigurationInterface
{
    /**
     * Array of supported resource owners, indentation is intentional to easily notice
     * which resource is of which type.
     *
     * @var array
     */
    private static $resourceOwners = array(
        'oauth2' => array(
            'amazon',
            'asana',
            'auth0',
            'azure',
            'bitbucket2',
            'bitly',
            'box',
            'bufferapp',
            'clever',
            'dailymotion',
            'deviantart',
            'deezer',
            'disqus',
            'eve_online',
            'eventbrite',
            'facebook',
            'fiware',
            'foursquare',
            'github',
            'gitlab',
            'google',
            'youtube',
            'hubic',
            'instagram',
            'jawbone',
            'linkedin',
            'mailru',
            'odnoklassniki',
            'office365',
            'paypal',
            'qq',
            'reddit',
            'runkeeper',
            'salesforce',
            'sensio_connect',
            'sina_weibo',
            'slack',
            'spotify',
            'soundcloud',
            'stack_exchange',
            'strava',
            'toshl',
            'trakt',
            'twitch',
            'vkontakte',
            'windows_live',
            'wordpress',
            'wunderlist',
            'yandex',
            '37signals',
            'itembase',
        ),
        'oauth1' => array(
            'bitbucket',
            'discogs',
            'dropbox',
            'flickr',
            'jira',
            'stereomood',
            'trello',
            'twitter',
            'xing',
            'yahoo',
        ),
    );

    /**
     * Return the type (OAuth1 or OAuth2) of given resource owner.
     *
     * @param string $resourceOwner
     *
     * @return string
     */
    public static function getResourceOwnerType($resourceOwner)
    {
        $resourceOwner = strtolower($resourceOwner);
        if ('oauth1' === $resourceOwner || 'oauth2' === $resourceOwner) {
            return $resourceOwner;
        }

        if (in_array($resourceOwner, static::$resourceOwners['oauth1'], true)) {
            return 'oauth1';
        }

        return 'oauth2';
    }

    /**
     * Checks that given resource owner is supported by this bundle.
     *
     * @param string $resourceOwner
     *
     * @return bool
     */
    public static function isResourceOwnerSupported($resourceOwner)
    {
        $resourceOwner = strtolower($resourceOwner);
        if ('oauth1' === $resourceOwner || 'oauth2' === $resourceOwner) {
            return true;
        }

        if (in_array($resourceOwner, static::$resourceOwners['oauth1'], true)) {
            return true;
        }

        return in_array($resourceOwner, static::$resourceOwners['oauth2'], true);
    }

    /**
     * Generates the configuration tree builder.
     *
     * @return TreeBuilder $builder The tree builder
     */
    public function getConfigTreeBuilder()
    {
        $builder = new TreeBuilder();

        $rootNode = $builder->root('hwi_oauth');
        $rootNode
            ->fixXmlConfig('firewall_name')
            ->children()
                ->arrayNode('firewall_names')
                    ->isRequired()
                    ->requiresAtLeastOneElement()
                    ->prototype('scalar')->end()
                ->end()
                ->scalarNode('target_path_parameter')->defaultNull()->end()
                ->booleanNode('use_referer')->defaultFalse()->end()
                ->booleanNode('failed_use_referer')->defaultFalse()->end()
                ->scalarNode('failed_auth_path')->defaultValue('hwi_oauth_connect')->end()
                ->scalarNode('grant_rule')
                    ->defaultValue('IS_AUTHENTICATED_REMEMBERED')
                    ->validate()
                        ->ifTrue(function ($role) {
                            return 'IS_AUTHENTICATED_REMEMBERED' !== $role || 'IS_AUTHENTICATED_FULLY' !== $role;
                        })
                        ->thenInvalid('Unknown grant role set "%s".')
                    ->end()
                ->end()
            ->end()
        ;

        $this->addHttpClientConfiguration($rootNode);
        $this->addConnectConfiguration($rootNode);
        $this->addFosubConfiguration($rootNode);
        $this->addResourceOwnersConfiguration($rootNode);

        return $builder;
    }
<commit_msg>Check for grant_rule value IS_AUTHENTICATED_FULLY<commit_after><?php

/*
 * This file is part of the HWIOAuthBundle package.
 *
 * (c) Hardware.Info <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace HWI\Bundle\OAuthBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * Configuration for the extension.
 *
 * @author Alexander <<EMAIL>>
 */
class Configuration implements ConfigurationInterface
{
    /**
     * Array of supported resource owners, indentation is intentional to easily notice
     * which resource is of which type.
     *
     * @var array
     */
    private static $resourceOwners = array(
        'oauth2' => array(
            'amazon',
            'asana',
            'auth0',
            'azure',
            'bitbucket2',
            'bitly',
            'box',
            'bufferapp',
            'clever',
            'dailymotion',
            'deviantart',
            'deezer',
            'disqus',
            'eve_online',
            'eventbrite',
            'facebook',
            'fiware',
            'foursquare',
            'github',
            'gitlab',
            'google',
            'youtube',
            'hubic',
            'instagram',
            'jawbone',
            'linkedin',
            'mailru',
            'odnoklassniki',
            'office365',
            'paypal',
            'qq',
            'reddit',
            'runkeeper',
            'salesforce',
            'sensio_connect',
            'sina_weibo',
            'slack',
            'spotify',
            'soundcloud',
            'stack_exchange',
            'strava',
            'toshl',
            'trakt',
            'twitch',
            'vkontakte',
            'windows_live',
            'wordpress',
            'wunderlist',
            'yandex',
            '37signals',
            'itembase',
        ),
        'oauth1' => array(
            'bitbucket',
            'discogs',
            'dropbox',
            'flickr',
            'jira',
            'stereomood',
            'trello',
            'twitter',
            'xing',
            'yahoo',
        ),
    );

    /**
     * Return the type (OAuth1 or OAuth2) of given resource owner.
     *
     * @param string $resourceOwner
     *
     * @return string
     */
    public static function getResourceOwnerType($resourceOwner)
    {
        $resourceOwner = strtolower($resourceOwner);
        if ('oauth1' === $resourceOwner || 'oauth2' === $resourceOwner) {
            return $resourceOwner;
        }

        if (in_array($resourceOwner, static::$resourceOwners['oauth1'], true)) {
            return 'oauth1';
        }

        return 'oauth2';
    }

    /**
     * Checks that given resource owner is supported by this bundle.
     *
     * @param string $resourceOwner
     *
     * @return bool
     */
    public static function isResourceOwnerSupported($resourceOwner)
    {
        $resourceOwner = strtolower($resourceOwner);
        if ('oauth1' === $resourceOwner || 'oauth2' === $resourceOwner) {
            return true;
        }

        if (in_array($resourceOwner, static::$resourceOwners['oauth1'], true)) {
            return true;
        }

        return in_array($resourceOwner, static::$resourceOwners['oauth2'], true);
    }

    /**
     * Generates the configuration tree builder.
     *
     * @return TreeBuilder $builder The tree builder
     */
    public function getConfigTreeBuilder()
    {
        $builder = new TreeBuilder();

        $rootNode = $builder->root('hwi_oauth');
        $rootNode
            ->fixXmlConfig('firewall_name')
            ->children()
                ->arrayNode('firewall_names')
                    ->isRequired()
                    ->requiresAtLeastOneElement()
                    ->prototype('scalar')->end()
                ->end()
                ->scalarNode('target_path_parameter')->defaultNull()->end()
                ->booleanNode('use_referer')->defaultFalse()->end()
                ->booleanNode('failed_use_referer')->defaultFalse()->end()
                ->scalarNode('failed_auth_path')->defaultValue('hwi_oauth_connect')->end()
                ->scalarNode('grant_rule')
                    ->defaultValue('IS_AUTHENTICATED_REMEMBERED')
                    ->validate()
                        ->ifTrue(function ($role) {
                            return !('IS_AUTHENTICATED_REMEMBERED' === $role || 'IS_AUTHENTICATED_FULLY' === $role);
                        })
                        ->thenInvalid('Unknown grant role set "%s".')
                    ->end()
                ->end()
            ->end()
        ;

        $this->addHttpClientConfiguration($rootNode);
        $this->addConnectConfiguration($rootNode);
        $this->addFosubConfiguration($rootNode);
        $this->addResourceOwnersConfiguration($rootNode);

        return $builder;
    }

{'fraction_non_alphanumeric': 0.12457387747151066, 'fraction_numerical': 0.0038959774033310605, 'mean_word_length': 1.6067529829906066, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '508303', 'n_tokens_mistral': 2766, 'n_tokens_neox': 2691, 'n_words': 538}