Failed Conditions
Push — ng ( 29d837...4fff42 )
by Florent
03:48
created

RequestObjectSource::continueLoading()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
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\Component\Endpoint\Authorization;
15
16
use Jose\Bundle\JoseFramework\Helper\ConfigurationHelper;
17
use OAuth2Framework\Bundle\Component\Component;
18
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\PropertyAccess\PropertyAccess;
21
22
class RequestObjectSource 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
Loading history...
23
{
24
    /**
25
     * AuthorizationEndpointRequestObjectSource constructor.
26
     */
27
    public function __construct()
28
    {
29
        $this->addSubSource(new RequestObjectReferenceSource());
0 ignored issues
show
Bug introduced by
The method addSubSource() does not seem to exist on object<OAuth2Framework\B...on\RequestObjectSource>.

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 RequestObjectEncryptionSource());
0 ignored issues
show
Bug introduced by
The method addSubSource() does not seem to exist on object<OAuth2Framework\B...on\RequestObjectSource>.

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
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    protected function continueLoading(string $path, ContainerBuilder $container, array $config)
37
    {
38
        foreach ($config as $k => $v) {
39
            $container->setParameter($path.'.'.$k, $v);
40
        }
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function name(): string
47
    {
48
        return 'request_object';
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode)
55
    {
56
        $node
57
            ->children()
58
                ->arrayNode('signature_algorithms')
59
                    ->info('Supported signature algorithms.')
60
                    ->useAttributeAsKey('name')
61
                    ->scalarPrototype()->end()
62
                    ->treatNullLike([])
63
                ->end()
64
            ->end();
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function prepend(array $bundleConfig, string $path, ContainerBuilder $container)
71
    {
72
        parent::prepend($bundleConfig, $path, $container);
73
        $currentPath = $path.'['.$this->name().']';
74
        $accessor = PropertyAccess::createPropertyAccessor();
75
        $sourceConfig = $accessor->getValue($bundleConfig, $currentPath);
76
        if (true === $sourceConfig['enabled']) {
77
            $claim_checkers = ['exp', 'iat', 'nbf'/*'authorization_endpoint_aud'*/]; // FIXME
78
            $header_checkers = ['crit']; // FIXME
0 ignored issues
show
Unused Code introduced by
$header_checkers is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
79
            ConfigurationHelper::addJWSLoader($container, $this->name(), $sourceConfig['signature_algorithms'], [], ['jws_compact'], false);
80
            ConfigurationHelper::addClaimChecker($container, $this->name(), $claim_checkers, false);
81
            if (true === $sourceConfig['encryption']['enabled']) {
82
                ConfigurationHelper::addJWELoader($container, $this->name(), $sourceConfig['encryption']['key_encryption_algorithms'], $sourceConfig['encryption']['content_encryption_algorithms'], ['DEF'], [], ['jwe_compact'], false);
83
            }
84
        }
85
    }
86
}
87