|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2016 SURFnet B.V. |
|
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\StepupMiddleware\ApiBundle\Controller; |
|
20
|
|
|
|
|
21
|
|
|
use Surfnet\Stepup\Configuration\Value\Institution; |
|
22
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\AllowedSecondFactorListService; |
|
23
|
|
|
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService; |
|
24
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
25
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
26
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
|
27
|
|
|
|
|
28
|
|
|
final class InstitutionConfigurationOptionsController extends Controller |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @var InstitutionConfigurationOptionsService |
|
32
|
|
|
*/ |
|
33
|
|
|
private $institutionConfigurationOptionsService; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var AllowedSecondFactorListService |
|
37
|
|
|
*/ |
|
38
|
|
|
private $allowedSecondFactorListService; |
|
39
|
|
|
|
|
40
|
|
|
public function __construct( |
|
41
|
|
|
InstitutionConfigurationOptionsService $institutionConfigurationOptionsService, |
|
42
|
|
|
AllowedSecondFactorListService $allowedSecondFactorListService |
|
43
|
|
|
) { |
|
44
|
|
|
$this->institutionConfigurationOptionsService = $institutionConfigurationOptionsService; |
|
45
|
|
|
$this->allowedSecondFactorListService = $allowedSecondFactorListService; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getForInstitutionAction($institutionName) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->denyAccessUnlessGranted(['ROLE_SS', 'ROLE_RA']); |
|
51
|
|
|
|
|
52
|
|
|
$institution = new Institution($institutionName); |
|
53
|
|
|
|
|
54
|
|
|
$institutionConfigurationOptions = $this |
|
55
|
|
|
->institutionConfigurationOptionsService |
|
56
|
|
|
->findInstitutionConfigurationOptionsFor($institution); |
|
57
|
|
|
|
|
58
|
|
|
$allowedSecondFactorList = $this |
|
59
|
|
|
->allowedSecondFactorListService |
|
60
|
|
|
->getAllowedSecondFactorListFor($institution); |
|
61
|
|
|
|
|
62
|
|
|
if ($institutionConfigurationOptions === null) { |
|
63
|
|
|
throw new NotFoundHttpException( |
|
64
|
|
|
sprintf('No institution configuration options found for institution "%s"', $institution) |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$numberOfTokensPerIdentity = $this |
|
69
|
|
|
->institutionConfigurationOptionsService |
|
70
|
|
|
->getMaxNumberOfTokensFor($institution); |
|
71
|
|
|
|
|
72
|
|
|
return new JsonResponse([ |
|
73
|
|
|
'institution' => $institutionConfigurationOptions->institution, |
|
74
|
|
|
'use_ra_locations' => $institutionConfigurationOptions->useRaLocationsOption, |
|
75
|
|
|
'show_raa_contact_information' => $institutionConfigurationOptions->showRaaContactInformationOption, |
|
76
|
|
|
'verify_email' => $institutionConfigurationOptions->verifyEmailOption, |
|
77
|
|
|
'number_of_tokens_per_identity' => $numberOfTokensPerIdentity, |
|
78
|
|
|
'allowed_second_factors' => $allowedSecondFactorList, |
|
79
|
|
|
]); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|