|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Copyright 2023 SURFnet bv |
|
7
|
|
|
* |
|
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
9
|
|
|
* you may not use this file except in compliance with the License. |
|
10
|
|
|
* You may obtain a copy of the License at |
|
11
|
|
|
* |
|
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
13
|
|
|
* |
|
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
17
|
|
|
* See the License for the specific language governing permissions and |
|
18
|
|
|
* limitations under the License. |
|
19
|
|
|
*/ |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
namespace Surfnet\StepupSelfService\SelfServiceBundle\Controller\Registration\Gssf; |
|
22
|
|
|
|
|
23
|
|
|
use Surfnet\SamlBundle\Http\XMLResponse; |
|
24
|
|
|
use Surfnet\StepupSelfService\SamlStepupProviderBundle\Provider\MetadataFactoryCollection; |
|
25
|
|
|
use Surfnet\StepupSelfService\SamlStepupProviderBundle\Provider\ProviderRepository; |
|
26
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Service\ControllerCheckerService; |
|
27
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
28
|
|
|
use Symfony\Component\Routing\Attribute\Route; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Controls registration with Generic SAML Stepup Providers (GSSPs), yielding Generic SAML Second Factors (GSSFs). |
|
32
|
|
|
*/ |
|
|
|
|
|
|
33
|
|
|
final class GssfMetadataController extends AbstractController |
|
34
|
|
|
{ |
|
35
|
|
|
public function __construct( |
|
|
|
|
|
|
36
|
|
|
private readonly ProviderRepository $providerRepository, |
|
37
|
|
|
private readonly MetadataFactoryCollection $metadataFactoryCollection, |
|
38
|
|
|
private readonly ControllerCheckerService $checkerService, |
|
39
|
|
|
) { |
|
40
|
|
|
} |
|
41
|
|
|
#[Route( |
|
|
|
|
|
|
42
|
|
|
path: '/registration/gssf/{provider}/metadata', |
|
|
|
|
|
|
43
|
|
|
name: 'ss_registration_gssf_saml_metadata', |
|
|
|
|
|
|
44
|
|
|
methods: ['GET'], |
|
|
|
|
|
|
45
|
|
|
)] |
|
|
|
|
|
|
46
|
|
|
public function metadata(string $provider): XMLResponse |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$this->checkerService->assertSecondFactorEnabled($provider); |
|
49
|
|
|
|
|
50
|
|
|
$provider = $this->providerRepository->get($provider); |
|
51
|
|
|
$factory = $this->metadataFactoryCollection->getByIdentifier($provider->getName()); |
|
52
|
|
|
|
|
53
|
|
|
return new XMLResponse($factory->generate()->__toString()); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
|