1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2019 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\SecurityBundle\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use OAuth2Framework\Component\BearerTokenType\BearerToken; |
17
|
|
|
use OAuth2Framework\Component\Core\AccessToken\AccessTokenHandler; |
18
|
|
|
use OAuth2Framework\Component\MacTokenType\MacToken; |
19
|
|
|
use OAuth2Framework\SecurityBundle\Annotation\Checker\Checker; |
20
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
21
|
|
|
use Symfony\Component\Config\Definition\Processor; |
22
|
|
|
use Symfony\Component\Config\FileLocator; |
23
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
24
|
|
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; |
25
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
26
|
|
|
|
27
|
|
|
final class OAuth2FrameworkSecurityExtension extends Extension |
28
|
|
|
{ |
29
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
30
|
|
|
{ |
31
|
|
|
$processor = new Processor(); |
32
|
|
|
$config = $processor->processConfiguration($this->getConfiguration($configs, $container), $configs); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$container->setAlias('oauth2_security.psr7_message_factory', $config['psr7_message_factory']); |
35
|
|
|
|
36
|
|
|
$container->registerForAutoconfiguration(Checker::class)->addTag('oauth2_security_annotation_checker'); |
37
|
|
|
$container->registerForAutoconfiguration(AccessTokenHandler::class)->addTag('oauth2_security_token_handler'); |
38
|
|
|
|
39
|
|
|
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/')); |
40
|
|
|
$loader->load('security.php'); |
41
|
|
|
|
42
|
|
|
/*if (true === $config['bearer_token']['enabled'] && class_exists(BearerToken::class)) { |
43
|
|
|
$container->setParameter('oauth2_security.token_type.bearer_token.realm', $config['bearer_token']['realm']); |
44
|
|
|
$loader->load('bearer_token.php'); |
45
|
|
|
|
46
|
|
|
$bearerTokenConfig = $config['bearer_token']; |
47
|
|
|
if (true === $bearerTokenConfig['authorization_header']) { |
48
|
|
|
$loader->load('authorization_header_token_finder.php'); |
49
|
|
|
} |
50
|
|
|
if (true === $bearerTokenConfig['query_string']) { |
51
|
|
|
$loader->load('query_string_token_finder.php'); |
52
|
|
|
} |
53
|
|
|
if (true === $bearerTokenConfig['request_body']) { |
54
|
|
|
$loader->load('request_body_token_finder.php'); |
55
|
|
|
} |
56
|
|
|
}*/ |
57
|
|
|
/*if (class_exists(MacToken::class) && $config['mac_token']['enabled']) { |
58
|
|
|
$container->setParameter('oauth2_security.token_type.mac_token.min_length', $config['mac_token']['min_length']); |
59
|
|
|
$container->setParameter('oauth2_security.token_type.mac_token.max_length', $config['mac_token']['max_length']); |
60
|
|
|
$container->setParameter('oauth2_security.token_type.mac_token.algorithm', $config['mac_token']['algorithm']); |
61
|
|
|
$container->setParameter('oauth2_security.token_type.mac_token.timestamp_lifetime', $config['mac_token']['timestamp_lifetime']); |
62
|
|
|
$loader->load('mac_token.php'); |
63
|
|
|
}*/ |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|