Skip to content

Commit f338aaf

Browse files
derhansenlolli42
authored andcommitted
[!!!][TASK] Remove static function parameter in AuthenticationService
The parameter `$passwordTransmissionStrategy` for the function `processLoginData` has a static value, which results back from the time, where ext:rsaauth has been removed from the core. Since the parameter has a static value, it has no value and should be removed. This patch removes the parameter for the affected function. Additionally, a meaningful description as well as strict return types have been added for the function. Resolves: #106869 Releases: main Signed-off-by: Torben Hansen <derhansen@gmail.com> Change-Id: I8c0fec8d19c55a79a38935d2da96ba72405329e9 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/89709 Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Georg Ringer <georg.ringer@gmail.com> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
1 parent 2e01e6a commit f338aaf

File tree

5 files changed

+60
-27
lines changed

5 files changed

+60
-27
lines changed

Build/phpstan/phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,6 @@ parameters:
474474
count: 1
475475
path: ../../typo3/sysext/core/Classes/Authentication/AbstractAuthenticationService.php
476476

477-
-
478-
message: '#^Comparison operation "\>\=" between 1 and 200 is always false\.$#'
479-
identifier: greaterOrEqual.alwaysFalse
480-
count: 1
481-
path: ../../typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
482-
483477
-
484478
message: '#^Left side of && is always true\.$#'
485479
identifier: booleanAnd.leftAlwaysTrue

typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ public function isActiveLogin(ServerRequestInterface $request): bool
11011101
* Processes Login data submitted by a form or params
11021102
*
11031103
* @param array $loginData Login data array
1104+
* @param ServerRequestInterface $request
11041105
* @return array
11051106
* @internal
11061107
*/
@@ -1112,7 +1113,7 @@ public function processLoginData(array $loginData, ServerRequestInterface $reque
11121113
$processedLoginData = $loginData;
11131114
/** @var AuthenticationService $serviceObject */
11141115
foreach ($this->getAuthServices($subType, $loginData, null, $request) as $serviceObject) {
1115-
$serviceResult = $serviceObject->processLoginData($processedLoginData, 'normal');
1116+
$serviceResult = $serviceObject->processLoginData($processedLoginData);
11161117
if (!empty($serviceResult)) {
11171118
$isLoginDataProcessed = true;
11181119
// If the service returns >=200 then no more processing is needed

typo3/sysext/core/Classes/Authentication/AuthenticationService.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,18 @@
3131
class AuthenticationService extends AbstractAuthenticationService implements MimicServiceInterface
3232
{
3333
/**
34-
* Process the submitted credentials.
35-
* In this case hash the clear text password if it has been submitted.
34+
* Process the submitted credentials. Returns true, if loginData was processed successfully, else false.
35+
* In addition, extensions overwriting this method or implement the context related methods `processLoginDataFE`
36+
* or `processLoginDataBE` may also return an int (e.g. >= 200) in order to stop loginData processing of other
37+
* services in the authentication service chain.
3638
*
3739
* @param array $loginData Credentials that are submitted and potentially modified by other services
38-
* @param string $passwordTransmissionStrategy Keyword of how the password has been hashed or encrypted before submission
39-
* @return bool
4040
*/
41-
public function processLoginData(array &$loginData, $passwordTransmissionStrategy)
41+
public function processLoginData(array &$loginData): bool|int
4242
{
43-
$isProcessed = false;
44-
if ($passwordTransmissionStrategy === 'normal') {
45-
$loginData = array_map(trim(...), $loginData);
46-
$loginData['uident_text'] = $loginData['uident'];
47-
$isProcessed = true;
48-
}
49-
return $isProcessed;
43+
$loginData = array_map(trim(...), $loginData);
44+
$loginData['uident_text'] = $loginData['uident'];
45+
return true;
5046
}
5147

5248
/**
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.. include:: /Includes.rst.txt
2+
3+
.. _breaking-106869-1749659916:
4+
5+
=============================================================================
6+
Breaking: #106869 - Remove static function parameter in AuthenticationService
7+
=============================================================================
8+
9+
See :issue:`106869`
10+
11+
Description
12+
===========
13+
14+
The parameter :php:`$passwordTransmissionStrategy`of the function
15+
:php:`TYPO3\CMS\Core\Authentication\processLoginData` has been removed.
16+
Additionally, the function does now use a strict return type.
17+
18+
19+
Impact
20+
======
21+
22+
Authentication services extending
23+
:php:`TYPO3\CMS\Core\Authentication\processLoginData` or implementing a
24+
subtype (e.g. :php:`processLoginDataBE` or :php:`processLoginDataFE`) will not
25+
be called with the :php:`$passwordTransmissionStrategy` parameter any more.
26+
27+
28+
Affected installations
29+
======================
30+
31+
Authentication services extending :php:`TYPO3\CMS\Core\Authentication\processLoginData`
32+
or implementing a subtype of the function.
33+
34+
35+
Migration
36+
=========
37+
38+
Extension extending :php:`TYPO3\CMS\Core\Authentication\processLoginData` must
39+
remove the parameter and additionally add :php:`bool|int` as return type for the
40+
function.
41+
42+
Extensions implementing a subtype of the function should remove the parameter,
43+
as it it not passed to subtype functions any more.
44+
45+
.. index:: Backend, NotScanned, ext:core

typo3/sysext/core/Tests/Unit/Authentication/AuthenticationServiceTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ protected function tearDown(): void
3838
public static function processLoginDataProvider(): array
3939
{
4040
return [
41-
'Backend login with securityLevel "normal"' => [
42-
'normal',
41+
'Backend login' => [
4342
[
4443
'status' => 'login',
4544
'uname' => 'admin',
@@ -52,8 +51,7 @@ public static function processLoginDataProvider(): array
5251
'uident_text' => 'password',
5352
],
5453
],
55-
'Frontend login with securityLevel "normal"' => [
56-
'normal',
54+
'Frontend login' => [
5755
[
5856
'status' => 'login',
5957
'uname' => 'admin',
@@ -66,8 +64,7 @@ public static function processLoginDataProvider(): array
6664
'uident_text' => 'password',
6765
],
6866
],
69-
'Frontend login with securityLevel "normal" and spaced passwords removes spaces' => [
70-
'normal',
67+
'Frontend login with spaced passwords removes spaces' => [
7168
[
7269
'status' => 'login',
7370
'uname' => 'admin ',
@@ -85,11 +82,11 @@ public static function processLoginDataProvider(): array
8582

8683
#[DataProvider('processLoginDataProvider')]
8784
#[Test]
88-
public function processLoginReturnsCorrectData(string $passwordSubmissionStrategy, array $loginData, array $expectedProcessedData): void
85+
public function processLoginReturnsCorrectData(array $loginData, array $expectedProcessedData): void
8986
{
9087
$subject = new AuthenticationService();
9188
// Login data is modified by reference
92-
$subject->processLoginData($loginData, $passwordSubmissionStrategy);
89+
$subject->processLoginData($loginData);
9390
self::assertEquals($expectedProcessedData, $loginData);
9491
}
9592

0 commit comments

Comments
 (0)