Passed
Push — bugfix/sso-cookie-writes-refin... ( 88520f...e0b851 )
by Michiel
15:36 queued 10:41
created

SecondFactorController::getSecondFactorService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
18
19
namespace Surfnet\StepupGateway\GatewayBundle\Controller;
20
21
use Psr\Log\LoggerInterface;
22
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
23
use Surfnet\StepupBundle\Command\VerifyPossessionOfPhoneCommand;
24
use Surfnet\StepupBundle\Value\PhoneNumber\InternationalPhoneNumber;
25
use Surfnet\StepupBundle\Value\SecondFactorType;
26
use Surfnet\StepupGateway\GatewayBundle\Command\ChooseSecondFactorCommand;
27
use Surfnet\StepupGateway\GatewayBundle\Command\SendSmsChallengeCommand;
28
use Surfnet\StepupGateway\GatewayBundle\Command\VerifyYubikeyOtpCommand;
29
use Surfnet\StepupGateway\GatewayBundle\Entity\SecondFactor;
30
use Surfnet\StepupGateway\GatewayBundle\Exception\InvalidArgumentException;
31
use Surfnet\StepupGateway\GatewayBundle\Exception\LoaCannotBeGivenException;
32
use Surfnet\StepupGateway\GatewayBundle\Exception\RuntimeException;
33
use Surfnet\StepupGateway\GatewayBundle\Form\Type\CancelAuthenticationType;
34
use Surfnet\StepupGateway\GatewayBundle\Form\Type\ChooseSecondFactorType;
35
use Surfnet\StepupGateway\GatewayBundle\Form\Type\SendSmsChallengeType;
36
use Surfnet\StepupGateway\GatewayBundle\Form\Type\VerifySmsChallengeType;
37
use Surfnet\StepupGateway\GatewayBundle\Form\Type\VerifyYubikeyOtpType;
38
use Surfnet\StepupGateway\GatewayBundle\Saml\ResponseContext;
39
use Surfnet\StepupGateway\GatewayBundle\Service\SecondFactorService;
40
use Surfnet\StepupGateway\GatewayBundle\Sso2fa\CookieService;
41
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
42
use Symfony\Component\Form\FormError;
43
use Symfony\Component\Form\FormInterface;
44
use Symfony\Component\HttpFoundation\RedirectResponse;
45
use Symfony\Component\HttpFoundation\Request;
46
use Symfony\Component\HttpFoundation\Response;
47
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
48
49
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
50
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
51
 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
52
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
53
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
54
class SecondFactorController extends Controller
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...e\Controller\Controller has been deprecated: since Symfony 4.2, use "Symfony\Bundle\FrameworkBundle\Controller\AbstractController" instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

54
class SecondFactorController extends /** @scrutinizer ignore-deprecated */ Controller
Loading history...
55
{
56
    const MODE_SFO = 'sfo';
57
    const MODE_SSO = 'sso';
58
59
    public function selectSecondFactorForVerificationSsoAction(Request $request)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function selectSecondFactorForVerificationSsoAction()
Loading history...
60
    {
61
        return $this->selectSecondFactorForVerificationAction(self::MODE_SSO, $request);
62
    }
63
64
    public function selectSecondFactorForVerificationSfoAction(Request $request)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function selectSecondFactorForVerificationSfoAction()
Loading history...
65
    {
66
        return $this->selectSecondFactorForVerificationAction(self::MODE_SFO, $request);
67
    }
68
69
    public function selectSecondFactorForVerificationAction($authenticationMode, Request $request)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function selectSecondFactorForVerificationAction()
Loading history...
70
    {
71
        $this->supportsAuthenticationMode($authenticationMode);
72
        $context = $this->getResponseContext($authenticationMode);
73
74
        $originalRequestId = $context->getInResponseTo();
75
76
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
77
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
78
        $logger->notice('Determining which second factor to use...');
79
80
        try {
81
            // Retrieve all requirements to determine the required LoA
82
            $requestedLoa = $context->getRequiredLoa();
83
            $spConfiguredLoas = $context->getServiceProvider()->get('configuredLoas');
84
85
            $identityNameId = $context->getIdentityNameId();
86
            $normalizedIdpSho = $context->getNormalizedSchacHomeOrganization();
87
            $normalizedUserSho = $this->getStepupService()->getNormalizedUserShoByIdentityNameId($identityNameId);
88
89
            $requiredLoa = $this
90
                ->getStepupService()
91
                ->resolveHighestRequiredLoa(
92
                    $requestedLoa,
93
                    $spConfiguredLoas,
0 ignored issues
show
Bug introduced by
It seems like $spConfiguredLoas can also be of type null; however, parameter $spConfiguredLoas of Surfnet\StepupGateway\Ga...lveHighestRequiredLoa() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

93
                    /** @scrutinizer ignore-type */ $spConfiguredLoas,
Loading history...
94
                    $normalizedIdpSho,
95
                    $normalizedUserSho
96
                );
97
        } catch (LoaCannotBeGivenException $e) {
98
            // Log the message of the domain exception, this contains a meaningful message.
99
            $logger->notice($e->getMessage());
100
101
            return $this->forward(
102
                'SurfnetStepupGatewayGatewayBundle:Gateway:sendLoaCannotBeGiven',
103
                ['authenticationMode' => $authenticationMode]
104
            );
105
        }
106
107
        $logger->notice(sprintf('Determined that the required Loa is "%s"', $requiredLoa));
108
109
        if ($this->getStepupService()->isIntrinsicLoa($requiredLoa)) {
110
            $this->get('gateway.authentication_logger')->logIntrinsicLoaAuthentication($originalRequestId);
111
            return $this->forward($context->getResponseAction());
0 ignored issues
show
Bug introduced by
It seems like $context->getResponseAction() can also be of type null; however, parameter $controller of Symfony\Bundle\Framework...r\Controller::forward() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

111
            return $this->forward(/** @scrutinizer ignore-type */ $context->getResponseAction());
Loading history...
112
        }
113
114
        $secondFactorCollection = $this
115
            ->getStepupService()
116
            ->determineViableSecondFactors(
117
                $context->getIdentityNameId(),
118
                $requiredLoa,
119
                $this->get('gateway.service.whitelist')
120
            );
121
122
        /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
123
         * @var CookieService $ssoCookieService
124
         */
125
        $ssoCookieService = $this->get('gateway.service.sso_2fa_cookie');
126
        $ssoCookie = $ssoCookieService->read($request);
127
        if ($ssoCookieService->shouldSkip2faAuthentication(
128
            $context,
129
            $requiredLoa->getLevel(),
130
            $identityNameId,
131
            $ssoCookie
132
        )) {
0 ignored issues
show
Coding Style introduced by
Closing parenthesis of a multi-line IF statement must be on a new line
Loading history...
133
            $logger->notice('Skipping second factor authentication. Required LoA was met by the LoA recorded in the cookie');
134
            // We use the SF from the cookie as the SF that was used for authenticating the second factor authentication
135
            $secondFactor = $this->getSecondFactorService()->findByUuid($ssoCookie->secondFactorId());
136
            $this->getResponseContext($authenticationMode)->saveSelectedSecondFactor($secondFactor);
0 ignored issues
show
Bug introduced by
It seems like $secondFactor can also be of type null; however, parameter $secondFactor of Surfnet\StepupGateway\Ga...eSelectedSecondFactor() does only seem to accept Surfnet\StepupGateway\Ga...dle\Entity\SecondFactor, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

136
            $this->getResponseContext($authenticationMode)->saveSelectedSecondFactor(/** @scrutinizer ignore-type */ $secondFactor);
Loading history...
137
            $this->getResponseContext($authenticationMode)->markSecondFactorVerified();
138
            $this->getResponseContext($authenticationMode)->markVerifiedBySsoOn2faCookie($ssoCookieService->getCookieFingerprint($request));
139
            $this->getAuthenticationLogger()->logSecondFactorAuthentication($originalRequestId, $authenticationMode);
0 ignored issues
show
Bug introduced by
It seems like $originalRequestId can also be of type null; however, parameter $requestId of Surfnet\StepupGateway\Ga...dFactorAuthentication() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

139
            $this->getAuthenticationLogger()->logSecondFactorAuthentication(/** @scrutinizer ignore-type */ $originalRequestId, $authenticationMode);
Loading history...
140
            return $this->forward($context->getResponseAction());
141
        }
142
        switch (count($secondFactorCollection)) {
143
            case 0:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
144
                $logger->notice('No second factors can give the determined Loa');
145
146
                return $this->forward(
147
                    'SurfnetStepupGatewayGatewayBundle:Gateway:sendLoaCannotBeGiven',
148
                    ['authenticationMode' => $authenticationMode]
149
                );
150
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
151
152
            case 1:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
153
                $secondFactor = $secondFactorCollection->first();
154
                $logger->notice(sprintf(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
155
                    'Found "%d" second factors, using second factor of type "%s"',
156
                    count($secondFactorCollection),
157
                    $secondFactor->secondFactorType
158
                ));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
159
160
                return $this->selectAndRedirectTo($secondFactor, $context, $authenticationMode);
161
                break;
162
163
            default:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
164
                return $this->forward(
165
                    'SurfnetStepupGatewayGatewayBundle:SecondFactor:chooseSecondFactor',
166
                    ['authenticationMode' => $authenticationMode, 'secondFactors' => $secondFactorCollection]
167
                );
168
                break;
169
        }
170
    }
171
172
    /**
173
     * The main WAYG screen
174
     * - Shows the token selection screen if you own > 1 token
175
     * - Directly goes to SF auth when identity owns 1 token
176
     *
177
     * @Template
0 ignored issues
show
Coding Style introduced by
Tag @Template cannot be grouped with parameter tags in a doc comment
Loading history...
178
     * @param Request $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 41 spaces but found 1
Loading history...
179
     * @param string $authenticationMode
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 41 spaces but found 1
Loading history...
180
     * @return array|RedirectResponse|Response
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 40 spaces but found 1
Loading history...
181
     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
0 ignored issues
show
Coding Style introduced by
Tag @SuppressWarnings(PHPMD.ExcessiveMethodLength) cannot be grouped with parameter tags in a doc comment
Loading history...
182
     */
183
    public function chooseSecondFactorAction(Request $request, $authenticationMode)
184
    {
185
        $this->supportsAuthenticationMode($authenticationMode);
186
        $context = $this->getResponseContext($authenticationMode);
187
        $originalRequestId = $context->getInResponseTo();
188
189
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
190
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
191
        $logger->notice('Ask the user which one of his suitable second factor tokens to use...');
192
193
        try {
194
            // Retrieve all requirements to determine the required LoA
195
            $requestedLoa = $context->getRequiredLoa();
196
            $spConfiguredLoas = $context->getServiceProvider()->get('configuredLoas');
197
198
            $normalizedIdpSho = $context->getNormalizedSchacHomeOrganization();
199
            $normalizedUserSho = $this->getStepupService()->getNormalizedUserShoByIdentityNameId($context->getIdentityNameId());
200
201
            $requiredLoa = $this
202
                ->getStepupService()
203
                ->resolveHighestRequiredLoa(
204
                    $requestedLoa,
205
                    $spConfiguredLoas,
0 ignored issues
show
Bug introduced by
It seems like $spConfiguredLoas can also be of type null; however, parameter $spConfiguredLoas of Surfnet\StepupGateway\Ga...lveHighestRequiredLoa() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

205
                    /** @scrutinizer ignore-type */ $spConfiguredLoas,
Loading history...
206
                    $normalizedIdpSho,
207
                    $normalizedUserSho
208
                );
209
        } catch (LoaCannotBeGivenException $e) {
210
            // Log the message of the domain exception, this contains a meaningful message.
211
            $logger->notice($e->getMessage());
212
            return $this->forward('SurfnetStepupGatewayGatewayBundle:Gateway:sendLoaCannotBeGiven');
213
        }
214
215
        $logger->notice(sprintf('Determined that the required Loa is "%s"', $requiredLoa));
216
217
        $secondFactors = $this
218
            ->getStepupService()
219
            ->determineViableSecondFactors(
220
                $context->getIdentityNameId(),
221
                $requiredLoa,
222
                $this->get('gateway.service.whitelist')
223
            );
224
225
        $command = new ChooseSecondFactorCommand();
226
        $command->secondFactors = $secondFactors;
0 ignored issues
show
Documentation Bug introduced by
It seems like $secondFactors of type Doctrine\Common\Collections\Collection is incompatible with the declared type Surfnet\StepupGateway\Ga...e\Entity\SecondFactor[] of property $secondFactors.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
227
228
        $form = $this
229
            ->createForm(
230
                ChooseSecondFactorType::class,
231
                $command,
232
                ['action' => $this->generateUrl('gateway_verify_second_factor_choose_second_factor', ['authenticationMode' => $authenticationMode])]
233
            )
234
            ->handleRequest($request);
235
        $cancelForm = $this->buildCancelAuthenticationForm($authenticationMode)->handleRequest($request);
236
237
        if ($form->isSubmitted() && $form->isValid()) {
238
            $buttonName = $form->getClickedButton()->getName();
0 ignored issues
show
Bug introduced by
The method getClickedButton() does not exist on Symfony\Component\Form\FormInterface. It seems like you code against a sub-type of Symfony\Component\Form\FormInterface such as Symfony\Component\Form\Form. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

238
            $buttonName = $form->/** @scrutinizer ignore-call */ getClickedButton()->getName();
Loading history...
239
            $formResults = $request->request->get('gateway_choose_second_factor', false);
240
241
            if (!isset($formResults[$buttonName])) {
242
                throw new InvalidArgumentException(
243
                    sprintf(
244
                        'Second factor type "%s" could not be found in the posted form results.',
245
                        $buttonName
246
                    )
247
                );
248
            }
249
250
            $secondFactorType = $formResults[$buttonName];
251
252
            // Filter the selected second factor from the array collection
253
            $secondFactorFiltered = $secondFactors->filter(
254
                function ($secondFactor) use ($secondFactorType) {
255
                    return $secondFactorType === $secondFactor->secondFactorType;
256
                }
257
            );
258
259
            if ($secondFactorFiltered->isEmpty()) {
260
                throw new InvalidArgumentException(
261
                    sprintf(
262
                        'Second factor type "%s" could not be found in the collection of available second factors.',
263
                        $secondFactorType
264
                    )
265
                );
266
            }
267
268
            $secondFactor = $secondFactorFiltered->first();
269
270
            $logger->notice(sprintf('User chose "%s" to use as second factor', $secondFactorType));
271
272
            // Forward to action to verify possession of second factor
273
            return $this->selectAndRedirectTo($secondFactor, $context, $authenticationMode);
274
        } else if ($form->isSubmitted() && !$form->isValid()) {
275
            $form->addError(
276
                new FormError(
277
                    $this->get('translator')
278
                      ->trans('gateway.form.gateway_choose_second_factor.unknown_second_factor_type')
0 ignored issues
show
Coding Style introduced by
Object operator not indented correctly; expected 24 spaces but found 22
Loading history...
279
                )
280
            );
281
        }
282
283
        return [
284
            'form' => $form->createView(),
285
            'cancelForm' => $cancelForm->createView(),
286
            'secondFactors' => $secondFactors,
287
        ];
288
    }
289
290
    public function verifyGssfAction(Request $request)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function verifyGssfAction()
Loading history...
291
    {
292
        if (!$request->get('authenticationMode', false)) {
293
            throw new RuntimeException('Unable to determine the authentication mode in the GSSP verification action');
294
        }
295
        $authenticationMode = $request->get('authenticationMode');
296
        $this->supportsAuthenticationMode($authenticationMode);
297
        $context = $this->getResponseContext($authenticationMode);
298
299
        $originalRequestId = $context->getInResponseTo();
300
301
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
302
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
303
        $logger->info('Received request to verify GSSF');
304
305
        $selectedSecondFactor = $this->getSelectedSecondFactor($context, $logger);
306
307
        $logger->info(sprintf(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
308
            'Selected GSSF "%s" for verfication, forwarding to Saml handling',
309
            $selectedSecondFactor
310
        ));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
311
312
        /** @var \Surfnet\StepupGateway\GatewayBundle\Service\SecondFactorService $secondFactorService */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
313
        $secondFactorService = $this->get('gateway.service.second_factor_service');
314
        /** @var \Surfnet\StepupGateway\GatewayBundle\Entity\SecondFactor $secondFactor */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
315
        $secondFactor = $secondFactorService->findByUuid($selectedSecondFactor);
316
        if (!$secondFactor) {
0 ignored issues
show
introduced by
$secondFactor is of type Surfnet\StepupGateway\Ga...dle\Entity\SecondFactor, thus it always evaluated to true.
Loading history...
317
            throw new RuntimeException(sprintf(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
318
                'Requested verification of GSSF "%s", however that Second Factor no longer exists',
319
                $selectedSecondFactor
320
            ));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
321
        }
322
323
        // Also send the response context service id, as later we need to know if this is regular SSO or SFO authn.
324
        $responseContextServiceId = $context->getResponseContextServiceId();
325
326
        return $this->forward(
327
            'SurfnetStepupGatewaySamlStepupProviderBundle:SamlProxy:sendSecondFactorVerificationAuthnRequest',
328
            [
329
                'provider' => $secondFactor->secondFactorType,
330
                'subjectNameId' => $secondFactor->secondFactorIdentifier,
331
                'responseContextServiceId' => $responseContextServiceId,
332
            ]
333
        );
334
    }
335
336
    public function gssfVerifiedAction(Request $request)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function gssfVerifiedAction()
Loading history...
337
    {
338
        $authenticationMode = $request->get('authenticationMode');
339
        $this->supportsAuthenticationMode($authenticationMode);
340
        $context = $this->getResponseContext($authenticationMode);
341
342
        $originalRequestId = $context->getInResponseTo();
343
344
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
345
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
346
        $logger->info('Attempting to mark GSSF as verified');
347
348
        $selectedSecondFactor = $this->getSelectedSecondFactor($context, $logger);
349
350
        /** @var \Surfnet\StepupGateway\GatewayBundle\Entity\SecondFactor $secondFactor */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
351
        $secondFactor = $this->get('gateway.service.second_factor_service')->findByUuid($selectedSecondFactor);
352
        if (!$secondFactor) {
0 ignored issues
show
introduced by
$secondFactor is of type Surfnet\StepupGateway\Ga...dle\Entity\SecondFactor, thus it always evaluated to true.
Loading history...
353
            throw new RuntimeException(
354
                sprintf(
355
                    'Verification of GSSF "%s" succeeded, however that Second Factor no longer exists',
356
                    $selectedSecondFactor
357
                )
358
            );
359
        }
360
361
        $this->getAuthenticationLogger()->logSecondFactorAuthentication($originalRequestId, $authenticationMode);
0 ignored issues
show
Bug introduced by
It seems like $originalRequestId can also be of type null; however, parameter $requestId of Surfnet\StepupGateway\Ga...dFactorAuthentication() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

361
        $this->getAuthenticationLogger()->logSecondFactorAuthentication(/** @scrutinizer ignore-type */ $originalRequestId, $authenticationMode);
Loading history...
362
        $context->markSecondFactorVerified();
363
364
        $logger->info(sprintf(
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
365
            'Marked GSSF "%s" as verified, forwarding to Gateway controller to respond',
366
            $selectedSecondFactor
367
        ));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
368
        return $this->forward($context->getResponseAction());
0 ignored issues
show
Bug introduced by
It seems like $context->getResponseAction() can also be of type null; however, parameter $controller of Symfony\Bundle\Framework...r\Controller::forward() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

368
        return $this->forward(/** @scrutinizer ignore-type */ $context->getResponseAction());
Loading history...
369
    }
370
371
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
372
     * @Template
0 ignored issues
show
Coding Style introduced by
Tag @Template cannot be grouped with parameter tags in a doc comment
Loading history...
373
     * @param Request $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 4 spaces but found 1
Loading history...
374
     * @return array|Response
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 3 spaces but found 1
Loading history...
375
     */
376
    public function verifyYubiKeySecondFactorAction(Request $request)
377
    {
378
        if (!$request->get('authenticationMode', false)) {
379
            throw new RuntimeException('Unable to determine the authentication mode in Yubikey verification action');
380
        }
381
        $authenticationMode = $request->get('authenticationMode');
382
        $this->supportsAuthenticationMode($authenticationMode);
383
        $context = $this->getResponseContext($authenticationMode);
384
        $originalRequestId = $context->getInResponseTo();
385
386
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
387
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
388
389
        $selectedSecondFactor = $this->getSelectedSecondFactor($context, $logger);
390
391
        $logger->notice('Verifying possession of Yubikey second factor');
392
393
        $command = new VerifyYubikeyOtpCommand();
394
        $command->secondFactorId = $selectedSecondFactor;
395
396
        $form = $this->createForm(VerifyYubikeyOtpType::class, $command)->handleRequest($request);
397
        $cancelForm = $this->buildCancelAuthenticationForm($authenticationMode)->handleRequest($request);
398
399
        if ($form->isSubmitted()  && $form->isValid()) {
400
            $result = $this->getStepupService()->verifyYubikeyOtp($command);
401
            if ($result->didOtpVerificationFail()) {
402
                $form->addError(
403
                    new FormError($this->get('translator')->trans('gateway.form.verify_yubikey.otp_verification_failed'))
404
                );
405
406
                // OTP field is rendered empty in the template.
407
                return ['form' => $form->createView(), 'cancelForm' => $cancelForm->createView()];
408
            } elseif (!$result->didPublicIdMatch()) {
409
                $form->addError(
410
                    new FormError($this->get('translator')->trans('gateway.form.verify_yubikey.public_id_mismatch'))
411
                );
412
413
                // OTP field is rendered empty in the template.
414
                return ['form' => $form->createView(), 'cancelForm' => $cancelForm->createView()];
415
            }
416
417
            $this->getResponseContext($authenticationMode)->markSecondFactorVerified();
418
            $this->getAuthenticationLogger()->logSecondFactorAuthentication($originalRequestId, $authenticationMode);
0 ignored issues
show
Bug introduced by
It seems like $originalRequestId can also be of type null; however, parameter $requestId of Surfnet\StepupGateway\Ga...dFactorAuthentication() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

418
            $this->getAuthenticationLogger()->logSecondFactorAuthentication(/** @scrutinizer ignore-type */ $originalRequestId, $authenticationMode);
Loading history...
419
420
            $logger->info(
421
                sprintf(
422
                    'Marked Yubikey Second Factor "%s" as verified, forwarding to Saml Proxy to respond',
423
                    $selectedSecondFactor
424
                )
425
            );
426
            return $this->forward($context->getResponseAction());
0 ignored issues
show
Bug introduced by
It seems like $context->getResponseAction() can also be of type null; however, parameter $controller of Symfony\Bundle\Framework...r\Controller::forward() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

426
            return $this->forward(/** @scrutinizer ignore-type */ $context->getResponseAction());
Loading history...
427
        }
428
429
        // OTP field is rendered empty in the template.
430
        return ['form' => $form->createView(), 'cancelForm' => $cancelForm->createView()];
431
    }
432
433
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
434
     * @Template
0 ignored issues
show
Coding Style introduced by
Tag @Template cannot be grouped with parameter tags in a doc comment
Loading history...
435
     * @param Request $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 4 spaces but found 1
Loading history...
436
     * @param string $authenticationMode
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Superfluous parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 4 spaces but found 1
Loading history...
437
     * @return array|Response
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 3 spaces but found 1
Loading history...
438
     */
439
    public function verifySmsSecondFactorAction(Request $request)
440
    {
441
        if (!$request->get('authenticationMode', false)) {
442
            throw new RuntimeException('Unable to determine the authentication mode in the SMS verification action');
443
        }
444
        $authenticationMode = $request->get('authenticationMode');
445
        $this->supportsAuthenticationMode($authenticationMode);
446
        $context = $this->getResponseContext($authenticationMode);
447
        $originalRequestId = $context->getInResponseTo();
448
449
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
450
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
451
452
        $selectedSecondFactor = $this->getSelectedSecondFactor($context, $logger);
453
454
        $logger->notice('Verifying possession of SMS second factor, preparing to send');
455
456
        $command = new SendSmsChallengeCommand();
457
        $command->secondFactorId = $selectedSecondFactor;
458
459
        $form = $this->createForm(SendSmsChallengeType::class, $command)->handleRequest($request);
460
        $cancelForm = $this->buildCancelAuthenticationForm($authenticationMode)->handleRequest($request);
461
462
        $stepupService = $this->getStepupService();
463
        $phoneNumber = InternationalPhoneNumber::fromStringFormat(
464
            $stepupService->getSecondFactorIdentifier($selectedSecondFactor)
465
        );
466
467
        $otpRequestsRemaining = $stepupService->getSmsOtpRequestsRemainingCount($selectedSecondFactor);
468
        $maximumOtpRequests = $stepupService->getSmsMaximumOtpRequestsCount();
469
        $viewVariables = ['otpRequestsRemaining' => $otpRequestsRemaining, 'maximumOtpRequests' => $maximumOtpRequests];
470
471
        if ($form->isSubmitted() && !$form->isValid()) {
472
            return array_merge(
473
                $viewVariables,
474
                [
475
                    'phoneNumber' => $phoneNumber,
476
                    'form' => $form->createView(),
477
                    'cancelForm' => $cancelForm->createView()
478
                ]
479
            );
480
        }
481
482
        $logger->notice('Verifying possession of SMS second factor, sending challenge per SMS');
483
484
        if (!$stepupService->sendSmsChallenge($command)) {
485
            $form->addError(
486
                new FormError($this->get('translator')->trans('gateway.form.send_sms_challenge.sms_sending_failed'))
487
            );
488
489
            return array_merge(
490
                $viewVariables,
491
                [
492
                    'phoneNumber' => $phoneNumber,
493
                    'form' => $form->createView(),
494
                    'cancelForm' => $cancelForm->createView()
495
                ]
496
            );
497
        }
498
        return $this->redirect(
499
            $this->generateUrl(
500
                'gateway_verify_second_factor_sms_verify_challenge',
501
                ['authenticationMode' => $authenticationMode]
502
            )
503
        );
504
    }
505
506
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
507
     * @Template
0 ignored issues
show
Coding Style introduced by
Tag @Template cannot be grouped with parameter tags in a doc comment
Loading history...
508
     * @param Request $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 4 spaces but found 1
Loading history...
509
     * @param string $authenticationMode
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Superfluous parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 4 spaces but found 1
Loading history...
510
     * @return array|Response
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 3 spaces but found 1
Loading history...
511
     */
512
    public function verifySmsSecondFactorChallengeAction(Request $request)
513
    {
514
        if (!$request->get('authenticationMode', false)) {
515
            throw new RuntimeException('Unable to determine the authentication mode in the SMS challenge action');
516
        }
517
        $authenticationMode = $request->get('authenticationMode');
518
        $this->supportsAuthenticationMode($authenticationMode);
519
        $context = $this->getResponseContext($authenticationMode);
520
        $originalRequestId = $context->getInResponseTo();
521
522
        /** @var \Surfnet\SamlBundle\Monolog\SamlAuthenticationLogger $logger */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
523
        $logger = $this->get('surfnet_saml.logger')->forAuthentication($originalRequestId);
524
525
        $selectedSecondFactor = $this->getSelectedSecondFactor($context, $logger);
526
527
        $command = new VerifyPossessionOfPhoneCommand();
528
        $form = $this->createForm(VerifySmsChallengeType::class, $command)->handleRequest($request);
529
        $cancelForm = $this->buildCancelAuthenticationForm($authenticationMode)->handleRequest($request);
530
531
        if ($form->isSubmitted() && $form->isValid()) {
532
            $logger->notice('Verifying input SMS challenge matches');
533
            $command->secondFactorId = $selectedSecondFactor;
534
            $verification = $this->getStepupService()->verifySmsChallenge($command);
535
536
            if ($verification->wasSuccessful()) {
537
                $this->getStepupService()->clearSmsVerificationState($selectedSecondFactor);
538
539
                $this->getResponseContext($authenticationMode)->markSecondFactorVerified();
540
                $this->getAuthenticationLogger()->logSecondFactorAuthentication($originalRequestId, $authenticationMode);
0 ignored issues
show
Bug introduced by
It seems like $originalRequestId can also be of type null; however, parameter $requestId of Surfnet\StepupGateway\Ga...dFactorAuthentication() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

540
                $this->getAuthenticationLogger()->logSecondFactorAuthentication(/** @scrutinizer ignore-type */ $originalRequestId, $authenticationMode);
Loading history...
541
542
                $logger->info(
543
                    sprintf(
544
                        'Marked Sms Second Factor "%s" as verified, forwarding to Saml Proxy to respond',
545
                        $selectedSecondFactor
546
                    )
547
                );
548
                return $this->forward($context->getResponseAction());
0 ignored issues
show
Bug introduced by
It seems like $context->getResponseAction() can also be of type null; however, parameter $controller of Symfony\Bundle\Framework...r\Controller::forward() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

548
                return $this->forward(/** @scrutinizer ignore-type */ $context->getResponseAction());
Loading history...
549
            } elseif ($verification->didOtpExpire()) {
550
                $logger->notice('SMS challenge expired');
551
                $form->addError(
552
                    new FormError($this->get('translator')->trans('gateway.form.send_sms_challenge.challenge_expired'))
553
                );
554
            } elseif ($verification->wasAttemptedTooManyTimes()) {
555
                $logger->notice('SMS challenge verification was attempted too many times');
556
                $form->addError(
557
                    new FormError($this->get('translator')->trans('gateway.form.send_sms_challenge.too_many_attempts'))
558
                );
559
            } else {
560
                $logger->notice('SMS challenge did not match');
561
                $form->addError(
562
                    new FormError(
563
                        $this->get('translator')->trans('gateway.form.send_sms_challenge.sms_challenge_incorrect')
564
                    )
565
                );
566
            }
567
        }
568
        return ['form' => $form->createView(), 'cancelForm' => $cancelForm->createView()];
569
    }
570
571
    public function cancelAuthenticationAction()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function cancelAuthenticationAction()
Loading history...
572
    {
573
        return $this->forward('SurfnetStepupGatewayGatewayBundle:Gateway:sendAuthenticationCancelledByUser');
574
    }
575
576
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
577
     * @return \Surfnet\StepupGateway\GatewayBundle\Service\StepupAuthenticationService
578
     */
579
    private function getStepupService()
0 ignored issues
show
Coding Style introduced by
Private method name "SecondFactorController::getStepupService" must be prefixed with an underscore
Loading history...
580
    {
581
        return $this->get('gateway.service.stepup_authentication');
582
    }
583
584
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $authenticationMode should have a doc-comment as per coding-style.
Loading history...
585
     * @return ResponseContext
586
     */
587
    private function getResponseContext($authenticationMode)
0 ignored issues
show
Coding Style introduced by
Private method name "SecondFactorController::getResponseContext" must be prefixed with an underscore
Loading history...
588
    {
589
        switch ($authenticationMode) {
590
            case self::MODE_SFO:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
591
                return $this->get($this->get('gateway.proxy.sfo.state_handler')->getResponseContextServiceId());
592
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
593
            case self::MODE_SSO:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 12
Loading history...
594
                return $this->get($this->get('gateway.proxy.sso.state_handler')->getResponseContextServiceId());
595
                break;
596
        }
597
    }
598
599
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
600
     * @return \Surfnet\StepupGateway\GatewayBundle\Monolog\Logger\AuthenticationLogger
601
     */
602
    private function getAuthenticationLogger()
0 ignored issues
show
Coding Style introduced by
Private method name "SecondFactorController::getAuthenticationLogger" must be prefixed with an underscore
Loading history...
603
    {
604
        return $this->get('gateway.authentication_logger');
605
    }
606
607
    private function getSecondFactorService(): SecondFactorService
0 ignored issues
show
Coding Style introduced by
Private method name "SecondFactorController::getSecondFactorService" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function getSecondFactorService()
Loading history...
608
    {
609
        return $this->get('gateway.service.second_factor_service');
610
    }
611
612
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
613
     * @param ResponseContext $context
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
614
     * @param LoggerInterface $logger
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
615
     * @return string
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
616
     */
617
    private function getSelectedSecondFactor(ResponseContext $context, LoggerInterface $logger)
0 ignored issues
show
Coding Style introduced by
Private method name "SecondFactorController::getSelectedSecondFactor" must be prefixed with an underscore
Loading history...
618
    {
619
        $selectedSecondFactor = $context->getSelectedSecondFactor();
620
621
        if (!$selectedSecondFactor) {
622
            $logger->error('Cannot verify possession of an unknown second factor');
623
624
            throw new BadRequestHttpException('Cannot verify possession of an unknown second factor.');
625
        }
626
627
        return $selectedSecondFactor;
628
    }
629
630
    private function selectAndRedirectTo(SecondFactor $secondFactor, ResponseContext $context, $authenticationMode)
0 ignored issues
show
Coding Style introduced by
Private method name "SecondFactorController::selectAndRedirectTo" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function selectAndRedirectTo()
Loading history...
631
    {
632
        $context->saveSelectedSecondFactor($secondFactor);
633
634
        $this->getStepupService()->clearSmsVerificationState($secondFactor->secondFactorId);
635
636
        $secondFactorTypeService = $this->get('surfnet_stepup.service.second_factor_type');
637
        $secondFactorType = new SecondFactorType($secondFactor->secondFactorType);
638
639
        $route = 'gateway_verify_second_factor_';
640
        if ($secondFactorTypeService->isGssf($secondFactorType)) {
641
            $route .= 'gssf';
642
        } else {
643
            $route .= strtolower($secondFactor->secondFactorType);
644
        }
645
646
        return $this->redirect($this->generateUrl($route, ['authenticationMode' => $authenticationMode]));
647
    }
648
649
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
650
     * @param string $authenticationMode
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
651
     * @return FormInterface
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
652
     */
653
    private function buildCancelAuthenticationForm($authenticationMode)
0 ignored issues
show
Coding Style introduced by
Private method name "SecondFactorController::buildCancelAuthenticationForm" must be prefixed with an underscore
Loading history...
654
    {
655
        $cancelFormAction = $this->generateUrl(
656
            'gateway_cancel_authentication',
657
            ['authenticationMode' => $authenticationMode]
658
        );
659
660
        return $this->createForm(
661
            CancelAuthenticationType::class,
662
            null,
663
            ['action' => $cancelFormAction]
664
        );
665
    }
666
667
    private function supportsAuthenticationMode($authenticationMode)
0 ignored issues
show
Coding Style introduced by
Private method name "SecondFactorController::supportsAuthenticationMode" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function supportsAuthenticationMode()
Loading history...
668
    {
669
        if (!($authenticationMode === self::MODE_SSO || $authenticationMode === self::MODE_SFO)) {
670
            throw new InvalidArgumentException('Invalid authentication mode requested');
671
        }
672
    }
673
}
674