Failed Conditions
Push — ng ( c00098...4b490a )
by Florent
06:57
created

AuthorizationEndpointSource   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 76
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A continueLoading() 0 9 2
A name() 0 4 1
B getNodeDefinition() 0 39 1
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\Component\Endpoint;
15
16
use Fluent\PhpConfigFileLoader;
17
use OAuth2Framework\Bundle\Component\Component;
18
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
19
use Symfony\Component\Config\FileLocator;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
22
class AuthorizationEndpointSource implements Component
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: build, load, prepend
Loading history...
23
{
24
    /**
25
     * AuthorizationEndpointSource constructor.
26
     */
27
    public function __construct()
28
    {
29
        $this->addSubSource(new AuthorizationEndpointRequestObjectSource());
0 ignored issues
show
Bug introduced by
The method addSubSource() does not seem to exist on object<OAuth2Framework\B...rizationEndpointSource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
        $this->addSubSource(new AuthorizationEndpointResponseModeSource());
0 ignored issues
show
Bug introduced by
The method addSubSource() does not seem to exist on object<OAuth2Framework\B...rizationEndpointSource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
        $this->addSubSource(new AuthorizationEndpointPreConfiguredAuthorizationSource());
0 ignored issues
show
Bug introduced by
The method addSubSource() does not seem to exist on object<OAuth2Framework\B...rizationEndpointSource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    protected function continueLoading(string $path, ContainerBuilder $container, array $config)
38
    {
39
        foreach ($config as $k => $v) {
40
            $container->setParameter($path.'.'.$k, $v);
41
        }
42
43
        $loader = new PhpConfigFileLoader($container, new FileLocator(__DIR__.'/../../Resources/config/endpoint'));
44
        $loader->load('authorization.php');
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function name(): string
51
    {
52
        return 'authorization';
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function getNodeDefinition(NodeDefinition $node)
59
    {
60
        $node
61
            ->children()
62
                ->scalarNode('path')
63
                    ->info('The path to the authorization endpoint.')
64
                    ->defaultValue('/authorize')
65
                ->end()
66
                ->scalarNode('login_route_name')
67
                    ->info('The name of the login route. Will be converted into URL and used to redirect the user if not logged in. If you use "FOSUserBundle", the route name should be "fos_user_security_login".')
68
                ->end()
69
                ->arrayNode('login_route_parameters')
70
                    ->info('Parameters associated to the login route (if needed).')
71
                    ->useAttributeAsKey('name')
72
                    ->prototype('scalar')->end()
73
                    ->treatNullLike([])
74
                ->end()
75
                ->scalarNode('template')
76
                    ->info('The consent page template.')
77
                    ->defaultValue('@OAuth2FrameworkBundle/authorization/authorization.html.twig')
78
                ->end()
79
                ->scalarNode('allow_token_type_parameter')
80
                    ->info('If true the "token_type" parameter is allowed, else it will be ignored.')
81
                    ->defaultFalse()
82
                ->end()
83
                ->scalarNode('enforce_state')
84
                    ->info('If true the "state" parameter is mandatory (highly recommended).')
85
                    ->defaultFalse()
86
                ->end()
87
                ->scalarNode('enforce_secured_redirect_uri')
88
                    ->info('If true only secured redirect URIs are allowed.')
89
                    ->defaultTrue()
90
                ->end()
91
                ->scalarNode('enforce_redirect_uri_storage')
92
                    ->info('If true redirect URIs must be registered by the client to be used.')
93
                    ->defaultTrue()
94
                ->end()
95
            ->end();
96
    }
97
}
98