1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 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\StepupSelfService\SelfServiceBundle\Controller; |
20
|
|
|
|
21
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Security\Authentication\AuthenticatedSessionStateHandler; |
22
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Service\ActivationFlowService; |
23
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Service\SecondFactorService; |
24
|
|
|
use Surfnet\StepupSelfService\SelfServiceBundle\Service\SelfAssertedTokens\RecoveryTokenService; |
25
|
|
|
use Symfony\Component\HttpFoundation\Request; |
26
|
|
|
use Symfony\Component\HttpKernel\Attribute\AsController; |
27
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
28
|
|
|
|
29
|
|
|
class EntryPointController extends Controller |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
public function __construct( |
|
|
|
|
32
|
|
|
private readonly SecondFactorService $secondFactorService, |
33
|
|
|
private readonly RecoveryTokenService $recoveryTokenService, |
34
|
|
|
private readonly ActivationFlowService $activationFlowService, |
35
|
|
|
private readonly AuthenticatedSessionStateHandler $authStateHandler |
36
|
|
|
) { |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
//ss_entry_point: |
|
|
|
|
40
|
|
|
//path: / |
|
|
|
|
41
|
|
|
//methods: [GET] |
|
|
|
|
42
|
|
|
//defaults: { _controller: SurfnetStepupSelfServiceSelfServiceBundle:EntryPoint:decideSecondFactorFlow } |
|
|
|
|
43
|
|
|
|
44
|
|
|
#[Route(path: '/', name: 'ss_entry_point', methods:['GET'] )] |
|
|
|
|
45
|
|
|
public function decideSecondFactorFlow(Request $request) |
|
|
|
|
46
|
|
|
{ |
|
|
|
|
47
|
|
|
$identity = $this->getIdentity(); |
48
|
|
|
$hasSecondFactor = $this->secondFactorService->doSecondFactorsExistForIdentity($identity->id); |
49
|
|
|
$hasRecoveryToken = $this->recoveryTokenService->hasRecoveryToken($identity); |
50
|
|
|
$this->activationFlowService->process($this->authStateHandler->getCurrentRequestUri()); |
51
|
|
|
|
52
|
|
|
if ($hasSecondFactor || $hasRecoveryToken) { |
53
|
|
|
return $this->redirect($this->generateUrl('ss_second_factor_list')); |
54
|
|
|
} else { |
55
|
|
|
return $this->redirect( |
56
|
|
|
$this->generateUrl('ss_registration_display_types') |
57
|
|
|
); |
58
|
|
|
} |
|
|
|
|
59
|
|
|
} |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|