Completed
Push — main ( a2ea13...6eca10 )
by
unknown
37s queued 33s
created

SamlAuthenticator::authenticate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Copyright 2024 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
 */
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...
20
21
namespace Surfnet\StepupSelfService\SelfServiceBundle\Security\Authentication;
22
23
use Surfnet\SamlBundle\Security\Authentication\SamlAuthenticator as StepupSamlAuthenticator;
24
use Surfnet\StepupSelfService\SelfServiceBundle\Service\ActivationFlowService;
25
use Symfony\Component\HttpFoundation\Request;
26
use Symfony\Component\HttpFoundation\Response;
27
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
28
use Symfony\Component\Security\Core\Exception\AuthenticationException;
29
use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface;
30
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
31
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
32
33
class SamlAuthenticator implements InteractiveAuthenticatorInterface, AuthenticationEntryPointInterface
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class SamlAuthenticator
Loading history...
34
{
35
    public function __construct(
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
36
        readonly private StepupSamlAuthenticator $authenticator,
37
        private readonly ActivationFlowService $activationFlowService,
38
    ) {
39
    }
40
41
    public function start(Request $request, ?AuthenticationException $authException = null): Response
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function start()
Loading history...
42
    {
43
        // Check if we need to do a registration flow nudge
44
        // This is used for when we are not logged in yet because the authentication is done in the Stepup-SAML-bundle
45
        $this->activationFlowService->processPreferenceFromUri($request->getUri());
46
        return $this->authenticator->start($request, $authException);
47
    }
48
49
    public function supports(Request $request): ?bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function supports()
Loading history...
50
    {
51
        return $this->authenticator->supports($request);
52
    }
53
54
    public function authenticate(Request $request): Passport
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function authenticate()
Loading history...
55
    {
56
        return $this->authenticator->authenticate($request);
57
    }
58
59
    public function createToken(Passport $passport, string $firewallName): TokenInterface
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function createToken()
Loading history...
60
    {
61
        return $this->authenticator->createToken($passport, $firewallName);
62
    }
63
64
    public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function onAuthenticationSuccess()
Loading history...
65
    {
66
        return $this->authenticator->onAuthenticationSuccess($request, $token, $firewallName);
67
    }
68
69
    public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function onAuthenticationFailure()
Loading history...
70
    {
71
        return $this->authenticator->onAuthenticationFailure($request, $exception);
72
    }
73
74
    public function isInteractive(): bool
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function isInteractive()
Loading history...
75
    {
76
        return $this->authenticator->isInteractive();
77
    }
78
}
79