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; |
15
|
|
|
|
16
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\OAuth2FrameworkExtension; |
17
|
|
|
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; |
18
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
19
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
20
|
|
|
|
21
|
|
|
class OAuth2FrameworkBundle extends Bundle |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var Component\Component[] |
25
|
|
|
*/ |
26
|
|
|
private $components = []; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* JoseFrameworkBundle constructor. |
30
|
|
|
*/ |
31
|
|
|
public function __construct() |
32
|
|
|
{ |
33
|
|
|
foreach ($this->getComponents() as $component) { |
34
|
|
|
$this->components[$component->name()] = $component; |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
41
|
|
|
public function boot() |
42
|
|
|
{ |
43
|
|
|
parent::boot(); |
44
|
|
|
//$this->container->get('twig.loader')->addPath(__DIR__.'/Resources/views', 'OAuth2FrameworkBundle'); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritdoc} |
49
|
|
|
*/ |
50
|
|
|
public function getContainerExtension() |
51
|
|
|
{ |
52
|
|
|
return new OAuth2FrameworkExtension('oauth2_server', $this->components); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function build(ContainerBuilder $container) |
59
|
|
|
{ |
60
|
|
|
parent::build($container); |
61
|
|
|
foreach ($this->components as $component) { |
62
|
|
|
$component->build($container); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/* @var SecurityExtension $extension */ |
66
|
|
|
//$extension = $container->getExtension('security'); |
|
|
|
|
67
|
|
|
//$extension->addSecurityListenerFactory(new OAuth2SecurityFactory()); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return Component\Component[] |
72
|
|
|
*/ |
73
|
|
|
private function getComponents(): array |
74
|
|
|
{ |
75
|
|
|
return [ |
76
|
|
|
new Component\Core\OAuth2ResponseSource(), |
77
|
|
|
new Component\Core\ClientSource(), |
78
|
|
|
new Component\Core\AccessTokenSource(), |
79
|
|
|
new Component\Core\UserAccountSource(), |
80
|
|
|
new Component\Core\ServicesSource(), |
81
|
|
|
new Component\Core\ResourceServerRepositorySource(), |
82
|
|
|
new Component\ClientRule\ClientRuleSource(), |
83
|
|
|
new Component\ClientAuthentication\ClientAuthenticationSource(), |
84
|
|
|
|
85
|
|
|
new Component\Scope\ScopeSource(), |
86
|
|
|
new Component\TokenType\TokenTypeSource(), |
87
|
|
|
new Component\Endpoint\EndpointSource(), |
88
|
|
|
new Component\Grant\GrantSource(), |
89
|
|
|
new Component\OpenIdConnect\OpenIdConnectSource(), |
90
|
|
|
|
91
|
|
|
/*new Component\FirewallSource(), |
|
|
|
|
92
|
|
|
new Component\HttpSource(), |
93
|
|
|
new Component\KeySet(),*/ |
94
|
|
|
]; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
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.