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 OAuth2Framework\Bundle\Component\Component; |
17
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
18
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
19
|
|
|
|
20
|
|
|
class RequestObjectEncryptionSource implements Component |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
public function load(array $configs, ContainerBuilder $container) |
26
|
|
|
{ |
27
|
|
|
/*foreach (['required', 'key_encryption_algorithms', 'content_encryption_algorithms'] as $k) { |
|
|
|
|
28
|
|
|
$container->setParameter($path.'.'.$k, $config[$k]); |
29
|
|
|
}*/ |
30
|
|
|
//$container->setAlias($path.'.key_set', 'jose.key_set.authorization_request_object.key_set.encryption'); |
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function name(): string |
37
|
|
|
{ |
38
|
|
|
return 'encryption'; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public function getNodeDefinition(ArrayNodeDefinition $node, ArrayNodeDefinition $rootNode) |
45
|
|
|
{ |
46
|
|
|
$node->children() |
47
|
|
|
->arrayNode($this->name()) |
48
|
|
|
->canBeEnabled() |
49
|
|
|
->children() |
50
|
|
|
->booleanNode('required') |
51
|
|
|
->info('If true, incoming request objects must be encrypted.') |
52
|
|
|
->defaultFalse() |
53
|
|
|
->end() |
54
|
|
|
->arrayNode('key_encryption_algorithms') |
55
|
|
|
->info('Supported key encryption algorithms.') |
56
|
|
|
->useAttributeAsKey('name') |
57
|
|
|
->scalarPrototype()->end() |
58
|
|
|
->treatNullLike([]) |
59
|
|
|
->end() |
60
|
|
|
->arrayNode('content_encryption_algorithms') |
61
|
|
|
->info('Supported content encryption algorithms.') |
62
|
|
|
->useAttributeAsKey('name') |
63
|
|
|
->scalarPrototype()->end() |
64
|
|
|
->treatNullLike([]) |
65
|
|
|
->end() |
66
|
|
|
->end() |
67
|
|
|
->end() |
68
|
|
|
->end(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function prepend(ContainerBuilder $container, array $config): array |
75
|
|
|
{ |
76
|
|
|
//Assertion::keyExists($bundleConfig['key_set'], 'encryption', 'The encryption key set must be enabled.'); |
|
|
|
|
77
|
|
|
//ConfigurationHelper::addKeyset($container, 'authorization_request_object.key_set.encryption', 'jwkset', ['value' => $bundleConfig['key_set']['encryption']]); |
|
|
|
|
78
|
|
|
return []; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritdoc} |
83
|
|
|
*/ |
84
|
|
|
public function build(ContainerBuilder $container) |
85
|
|
|
{ |
86
|
|
|
// Nothing to do |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.