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
|
|
|
protected function continueLoading(string $path, ContainerBuilder $container, array $config) |
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 |
47
|
|
|
->children() |
48
|
|
|
->booleanNode('required') |
49
|
|
|
->info('If true, incoming request objects must be encrypted.') |
50
|
|
|
->defaultFalse() |
51
|
|
|
->end() |
52
|
|
|
->arrayNode('key_encryption_algorithms') |
53
|
|
|
->info('Supported key encryption algorithms.') |
54
|
|
|
->useAttributeAsKey('name') |
55
|
|
|
->scalarPrototype()->end() |
56
|
|
|
->treatNullLike([]) |
57
|
|
|
->end() |
58
|
|
|
->arrayNode('content_encryption_algorithms') |
59
|
|
|
->info('Supported content encryption 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
|
|
|
|
74
|
|
|
Assertion::keyExists($bundleConfig['key_set'], 'encryption', 'The encryption key set must be enabled.'); |
75
|
|
|
//ConfigurationHelper::addKeyset($container, 'authorization_request_object.key_set.encryption', 'jwkset', ['value' => $bundleConfig['key_set']['encryption']]); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|