-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOAuth2FrameworkSecurityBundle.php
More file actions
49 lines (42 loc) · 1.87 KB
/
OAuth2FrameworkSecurityBundle.php
File metadata and controls
49 lines (42 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2019 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace OAuth2Framework\SecurityBundle;
use OAuth2Framework\SecurityBundle\DependencyInjection\Compiler\AccessTokenHandlerCompilerPass;
use OAuth2Framework\SecurityBundle\DependencyInjection\Compiler\SecurityAnnotationCheckerCompilerPass;
use OAuth2Framework\SecurityBundle\DependencyInjection\Compiler\TokenTypeCompilerPass;
use OAuth2Framework\SecurityBundle\DependencyInjection\OAuth2FrameworkSecurityExtension;
use OAuth2Framework\SecurityBundle\Security\Factory\OAuth2SecurityFactory;
use RuntimeException;
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;
final class OAuth2FrameworkSecurityBundle extends Bundle
{
public function getContainerExtension(): ExtensionInterface
{
return new OAuth2FrameworkSecurityExtension();
}
public function build(ContainerBuilder $container): void
{
if (!$container->hasExtension('security')) {
throw new RuntimeException('The security extension is not available');
}
$extension = $container->getExtension('security');
if (!$extension instanceof SecurityExtension) {
throw new RuntimeException('Unsupported security extension');
}
$extension->addSecurityListenerFactory(new OAuth2SecurityFactory());
$container->addCompilerPass(new SecurityAnnotationCheckerCompilerPass());
$container->addCompilerPass(new AccessTokenHandlerCompilerPass());
$container->addCompilerPass(new TokenTypeCompilerPass());
}
}