1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2016 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupGateway\SecondFactorOnlyBundle\Controller; |
20
|
|
|
|
21
|
|
|
use Psr\Log\LoggerInterface; |
22
|
|
|
use Surfnet\SamlBundle\Http\XMLResponse; |
23
|
|
|
use Surfnet\SamlBundle\Metadata\MetadataFactory; |
24
|
|
|
use Surfnet\StepupGateway\GatewayBundle\Container\ContainerController; |
25
|
|
|
use Symfony\Component\Routing\Attribute\Route; |
26
|
|
|
|
27
|
|
|
class MetadataController extends ContainerController |
28
|
|
|
{ |
29
|
|
|
public function __construct( |
30
|
|
|
private readonly LoggerInterface $logger, |
31
|
|
|
private readonly MetadataFactory $metadataFactory, |
32
|
|
|
private readonly bool $secondFactorEnabled, |
33
|
|
|
) { |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
#[Route( |
37
|
|
|
path: '/second-factor-only/metadata', |
38
|
|
|
name: 'gateway_second_factor_only_metadata', |
39
|
|
|
methods: ['GET'] |
40
|
|
|
)] |
41
|
|
|
public function metadata(): XMLResponse |
42
|
|
|
{ |
43
|
|
|
if (!$this->secondFactorEnabled) { |
44
|
|
|
$this->logger->notice(sprintf( |
45
|
|
|
'Access to %s denied, second_factor_only parameter set to false.', |
46
|
|
|
__METHOD__, |
47
|
|
|
)); |
48
|
|
|
throw $this->createAccessDeniedException('Second Factor Only feature disabled'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return new XMLResponse($this->metadataFactory->generate()); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|