|
33 | 33 | use Surfnet\StepupBundle\Service\LoaResolutionService;
|
34 | 34 | use Surfnet\StepupBundle\Value\Loa;
|
35 | 35 | use Surfnet\StepupSelfService\SelfServiceBundle\Controller\SelfVet\SelfVetController;
|
| 36 | +use Surfnet\StepupSelfService\SelfServiceBundle\Security\Authentication\SamlAuthenticationStateHandler; |
| 37 | +use Surfnet\StepupSelfService\SelfServiceBundle\Security\Authentication\Session\SessionStorage; |
36 | 38 | use Surfnet\StepupSelfService\SelfServiceBundle\Service\SecondFactorService;
|
37 | 39 | use Surfnet\StepupSelfService\SelfServiceBundle\Service\SelfAssertedTokens\RecoveryTokenState;
|
38 | 40 | use Surfnet\StepupSelfService\SelfServiceBundle\Service\TestSecondFactor\TestAuthenticationRequestFactory;
|
@@ -63,6 +65,7 @@ public function __construct(
|
63 | 65 | private readonly LoaResolutionService $loaResolutionService,
|
64 | 66 | private readonly MetadataFactory $metadataFactory,
|
65 | 67 | private readonly SamlAuthenticationLogger $samlAuthenticationLogger,
|
| 68 | + private readonly SessionStorage $authenticationStateHandler, |
66 | 69 | private readonly TestAuthenticationRequestFactory $testAuthenticationRequestFactory,
|
67 | 70 | private readonly RedirectBinding $redirectBinding,
|
68 | 71 | private readonly PostBinding $postBinding,
|
@@ -103,7 +106,7 @@ public function testSecondFactor(): RedirectResponse
|
103 | 106 | $this->loaResolutionService->getLoaByLevel(Loa::LOA_SELF_VETTED),
|
104 | 107 | );
|
105 | 108 |
|
106 |
| - $this->requestStack->getSession()->set('second_factor_test_request_id', $authenticationRequest->getRequestId()); |
| 109 | + $this->authenticationStateHandler->setRequestId($authenticationRequest->getRequestId()); |
107 | 110 |
|
108 | 111 | $samlLogger = $this->samlAuthenticationLogger->forAuthentication($authenticationRequest->getRequestId());
|
109 | 112 | $samlLogger->notice('Sending authentication request to the second factor test IDP');
|
@@ -135,17 +138,17 @@ public function consumeAssertion(Request $httpRequest): Response
|
135 | 138 | // verification a different session id is used to mark the authentication.
|
136 | 139 | return $this->forward('Surfnet\StepupSelfService\SelfServiceBundle\Controller\RecoveryTokenController::stepUpConsumeAssertion');
|
137 | 140 | }
|
138 |
| - if (!$session->has('second_factor_test_request_id')) { |
| 141 | + if (!$this->authenticationStateHandler->hasRequestId()) { |
139 | 142 | $this->logger->error(
|
140 | 143 | 'Received an authentication response for testing a second factor, but no second factor test response was expected',
|
141 | 144 | );
|
142 | 145 |
|
143 | 146 | throw new AccessDeniedHttpException('Did not expect an authentication response');
|
144 | 147 | }
|
145 | 148 | $this->logger->notice('Received an authentication response for testing a second factor');
|
146 |
| - $initiatedRequestId = $session->get('second_factor_test_request_id'); |
| 149 | + $initiatedRequestId = $this->authenticationStateHandler->getRequestId(); |
147 | 150 | $samlLogger = $this->samlAuthenticationLogger->forAuthentication($initiatedRequestId);
|
148 |
| - $session->remove('second_factor_test_request_id'); |
| 151 | + $this->authenticationStateHandler->clearRequestId(); |
149 | 152 | try {
|
150 | 153 | $assertion = $this->postBinding->processResponse(
|
151 | 154 | $httpRequest,
|
|
0 commit comments