Failed Conditions
Push — ng ( 962349...975869 )
by Florent
03:54
created

PairwiseSubjectSource::continueLoading()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Bundle\DependencyInjection\Component\OpenIdConnect;
15
16
use OAuth2Framework\Bundle\DependencyInjection\Component\Component;
17
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\AuthorizationCode\AuthorizationCodeSource;
18
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\ClientCredentials\ClientCredentialsSource;
19
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\Implicit\ImplicitSource;
20
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\JwtBearer\JwtBearerSource;
21
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\None\NoneSource;
22
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\RefreshToken\RefreshTokenSource;
23
use OAuth2Framework\Bundle\DependencyInjection\Component\Grant\ResourceOwnerPasswordCredential\ResourceOwnerPasswordCredentialSource;
24
use OAuth2Framework\Component\AuthorizationEndpoint\ResponseType;
25
use OAuth2Framework\Component\TokenEndpoint\GrantType;
26
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
27
use Symfony\Component\Config\FileLocator;
28
use Symfony\Component\DependencyInjection\ContainerBuilder;
29
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
30
31
class PairwiseSubjectSource implements Component
32
{
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function name(): string
37
    {
38
        return 'pairwise_subject';
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function load(array $configs, ContainerBuilder $container)
45
    {
46
        if (!$configs['openid_connect']['pairwise_subject']['enabled']) {
47
            return;
48
        }
49
50
        $container->setAlias('oauth2_server.openid_connect.pairwise.service', $configs['openid_connect']['pairwise_subject']['service']);
51
        $container->setParameter('oauth2_server.openid_connect.pairwise.is_default', $configs['openid_connect']['pairwise_subject']['is_default']);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getNodeDefinition(NodeDefinition $node)
58
    {
59
        $node->children()
60
            ->arrayNode($this->name())
61
                ->canBeEnabled()
62
                ->addDefaultsIfNotSet()
63
                ->validate()
64
                    ->ifTrue(function ($config) {
65
                        return true === $config['enabled'] && empty($config['service']);
66
                    })
67
                    ->thenInvalid('The pairwise subject service must be set.')
68
                ->end()
69
                ->children()
70
                    ->scalarNode('service')
71
                    ->end()
72
                    ->booleanNode('is_default')
73
                        ->defaultTrue()
74
                    ->end()
75
                ->end()
76
            ->end()
77
        ->end();
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function prepend(ContainerBuilder $container, array $config): array
84
    {
85
        return [];
86
    }
87
}
88