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 |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* AuthorizationEndpointRequestObjectSource constructor. |
26
|
|
|
*/ |
27
|
|
|
public function __construct() |
28
|
|
|
{ |
29
|
|
|
$this->addSubSource(new RequestObjectReferenceSource()); |
|
|
|
|
30
|
|
|
$this->addSubSource(new RequestObjectEncryptionSource()); |
|
|
|
|
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 |
|
|
|
|
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
|
|
|
|