|
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\Endpoint; |
|
15
|
|
|
|
|
16
|
|
|
use Jose\Bundle\JoseFramework\Helper\ConfigurationHelper; |
|
17
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Component; |
|
18
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
20
|
|
|
use Symfony\Component\PropertyAccess\PropertyAccess; |
|
21
|
|
|
|
|
22
|
|
|
final class SignedMetadataEndpointSource implements Component |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* {@inheritdoc} |
|
26
|
|
|
*/ |
|
27
|
|
|
protected function continueLoading(string $path, ContainerBuilder $container, array $config) |
|
28
|
|
|
{ |
|
29
|
|
|
$container->setParameter($path.'.algorithm', $config['algorithm']); |
|
30
|
|
|
//$container->setAlias($path.'.key_set', 'jose.key_set.signed_metadata_endpoint.key_set.signature'); |
|
|
|
|
|
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
public function name(): string |
|
37
|
|
|
{ |
|
38
|
|
|
return 'signature'; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* {@inheritdoc} |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getNodeDefinition(NodeDefinition $node) |
|
45
|
|
|
{ |
|
46
|
|
|
|
|
47
|
|
|
$node |
|
|
|
|
|
|
48
|
|
|
->validate() |
|
49
|
|
|
->ifTrue(function ($config) { |
|
50
|
|
|
return true === $config['enabled'] && empty($config['algorithm']); |
|
51
|
|
|
}) |
|
52
|
|
|
->thenInvalid('The parameter "algorithm" must be set.') |
|
53
|
|
|
->end() |
|
54
|
|
|
->children() |
|
55
|
|
|
->scalarNode('algorithm') |
|
56
|
|
|
->info('Signature algorithm used to sign the metadata.') |
|
57
|
|
|
->end() |
|
58
|
|
|
->end(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function prepend(array $bundleConfig, string $path, ContainerBuilder $container) |
|
62
|
|
|
{ |
|
63
|
|
|
parent::prepend($bundleConfig, $path, $container); |
|
64
|
|
|
$currentPath = $path.'['.$this->name().']'; |
|
65
|
|
|
$accessor = PropertyAccess::createPropertyAccessor(); |
|
66
|
|
|
$sourceConfig = $accessor->getValue($bundleConfig, $currentPath); |
|
67
|
|
|
|
|
68
|
|
|
ConfigurationHelper::addJWSBuilder($container, 'metadata_signature', [$sourceConfig['algorithm']], false); |
|
69
|
|
|
|
|
70
|
|
|
Assertion::keyExists($bundleConfig['key_set'], 'signature', 'The signature key set must be enabled.'); |
|
71
|
|
|
//ConfigurationHelper::addKeyset($container, 'signed_metadata_endpoint.key_set.signature', 'jwkset', ['value' => $bundleConfig['key_set']['signature']]); |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|