Skip to content

Commit 235f6a7

Browse files
Merge branch '6.0' into 6.1
* 6.0: [Serializer] Fix denormalizing union types [HttpFoundation] Remove obsolete override bug symfony#42637 [Security] Fixed TOCTOU in RememberMe cache token verifier Fix compatibility of ldap 6.0 with security 5.x Add missing upgrade note for ldap [Mailer] Preserve case of headers
2 parents 753c846 + 504e4b8 commit 235f6a7

File tree

16 files changed

+230
-115
lines changed

16 files changed

+230
-115
lines changed

Diff for: UPGRADE-6.0.md

+5
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ Inflector
146146

147147
* The component has been removed, use `EnglishInflector` from the String component instead.
148148

149+
Ldap
150+
----
151+
152+
* Remove `LdapAuthenticator::createAuthenticatedToken()`, use `LdapAuthenticator::createToken()` instead
153+
149154
Lock
150155
----
151156

Diff for: src/Symfony/Component/HttpFoundation/InputBag.php

-8
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ public function get(string $key, mixed $default = null): string|int|float|bool|n
4040
return $this === $value ? $default : $value;
4141
}
4242

43-
/**
44-
* {@inheritdoc}
45-
*/
46-
public function all(string $key = null): array
47-
{
48-
return parent::all($key);
49-
}
50-
5143
/**
5244
* Replaces the current input values by a new set.
5345
*/

Diff for: src/Symfony/Component/Ldap/Security/LdapAuthenticator.php

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
1919
use Symfony\Component\Security\Http\Authenticator\InteractiveAuthenticatorInterface;
2020
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
21+
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
2122
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
2223
use Symfony\Component\Security\Http\EntryPoint\Exception\NotAnEntryPointException;
2324

@@ -64,6 +65,14 @@ public function authenticate(Request $request): Passport
6465
return $passport;
6566
}
6667

68+
/**
69+
* @internal
70+
*/
71+
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
72+
{
73+
throw new \BadMethodCallException(sprintf('The "%s()" method cannot be called.', __METHOD__));
74+
}
75+
6776
public function createToken(Passport $passport, string $firewallName): TokenInterface
6877
{
6978
return $this->authenticator->createToken($passport, $firewallName);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Ldap\Tests\Security;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\Ldap\Security\LdapAuthenticator;
17+
use Symfony\Component\Ldap\Security\LdapBadge;
18+
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
19+
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
20+
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
21+
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
22+
23+
class LdapAuthenticatorTest extends TestCase
24+
{
25+
public function testAuthenticate()
26+
{
27+
$decorated = $this->createMock(AuthenticatorInterface::class);
28+
$passport = new Passport(new UserBadge('test'), new PasswordCredentials('s3cret'));
29+
$decorated
30+
->expects($this->once())
31+
->method('authenticate')
32+
->willReturn($passport)
33+
;
34+
35+
$authenticator = new LdapAuthenticator($decorated, 'serviceId');
36+
$request = new Request();
37+
38+
$authenticator->authenticate($request);
39+
40+
/** @var LdapBadge $badge */
41+
$badge = $passport->getBadge(LdapBadge::class);
42+
$this->assertNotNull($badge);
43+
$this->assertSame('serviceId', $badge->getLdapServiceId());
44+
}
45+
}

Diff for: src/Symfony/Component/Ldap/composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"symfony/options-resolver": "^5.4|^6.0"
2222
},
2323
"require-dev": {
24-
"symfony/security-core": "^5.4|^6.0"
24+
"symfony/security-core": "^5.4|^6.0",
25+
"symfony/security-http": "^5.4|^6.0"
2526
},
2627
"conflict": {
2728
"symfony/options-resolver": "<5.4",

Diff for: src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private function getPayload(Email $email, Envelope $envelope): array
138138
continue;
139139
}
140140

141-
$payload['message']['headers'][$name] = $header->getBodyAsString();
141+
$payload['message']['headers'][$header->getName()] = $header->getBodyAsString();
142142
}
143143

144144
return $payload;

Diff for: src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunApiTransportTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function testCustomHeader()
7575
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
7676
$payload = $method->invoke($transport, $email, $envelope);
7777

78-
$this->assertArrayHasKey('h:x-mailgun-variables', $payload);
79-
$this->assertEquals($json, $payload['h:x-mailgun-variables']);
78+
$this->assertArrayHasKey('h:X-Mailgun-Variables', $payload);
79+
$this->assertEquals($json, $payload['h:X-Mailgun-Variables']);
8080

8181
$this->assertArrayHasKey('h:foo', $payload);
8282
$this->assertEquals('foo-value', $payload['h:foo']);
@@ -254,10 +254,10 @@ public function testTagAndMetadataHeaders()
254254
$transport = new MailgunApiTransport('ACCESS_KEY', 'DOMAIN');
255255
$method = new \ReflectionMethod(MailgunApiTransport::class, 'getPayload');
256256
$payload = $method->invoke($transport, $email, $envelope);
257-
$this->assertArrayHasKey('h:x-mailgun-variables', $payload);
258-
$this->assertEquals($json, $payload['h:x-mailgun-variables']);
259-
$this->assertArrayHasKey('h:custom-header', $payload);
260-
$this->assertEquals('value', $payload['h:custom-header']);
257+
$this->assertArrayHasKey('h:X-Mailgun-Variables', $payload);
258+
$this->assertEquals($json, $payload['h:X-Mailgun-Variables']);
259+
$this->assertArrayHasKey('h:Custom-Header', $payload);
260+
$this->assertEquals('value', $payload['h:Custom-Header']);
261261
$this->assertArrayHasKey(0, $payload);
262262
$this->assertArrayHasKey(1, $payload);
263263
$this->assertSame('password-reset', $payload[0]['o:tag']);

Diff for: src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ private function getPayload(Email $email, Envelope $envelope): array
137137
// Check if it is a valid prefix or header name according to Mailgun API
138138
$prefix = substr($name, 0, 2);
139139
if (\in_array($prefix, ['h:', 't:', 'o:', 'v:']) || \in_array($name, ['recipient-variables', 'template', 'amp-html'])) {
140-
$headerName = $name;
140+
$headerName = $header->getName();
141141
} else {
142-
$headerName = 'h:'.$name;
142+
$headerName = 'h:'.$header->getName();
143143
}
144144

145145
$payload[$headerName] = $header->getBodyAsString();

Diff for: src/Symfony/Component/Mailer/Bridge/OhMySmtp/Transport/OhMySmtpApiTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function getPayload(Email $email, Envelope $envelope): array
103103
}
104104

105105
$payload['Headers'][] = [
106-
'Name' => $name,
106+
'Name' => $header->getName(),
107107
'Value' => $header->getBodyAsString(),
108108
];
109109
}

Diff for: src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private function getPayload(Email $email, Envelope $envelope): array
120120
}
121121

122122
$payload['Headers'][] = [
123-
'Name' => $name,
123+
'Name' => $header->getName(),
124124
'Value' => $header->getBodyAsString(),
125125
];
126126
}

Diff for: src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridApiTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private function getPayload(Email $email, Envelope $envelope): array
133133
} elseif ($header instanceof MetadataHeader) {
134134
$customArguments[$header->getKey()] = $header->getValue();
135135
} else {
136-
$payload['headers'][$name] = $header->getBodyAsString();
136+
$payload['headers'][$header->getName()] = $header->getBodyAsString();
137137
}
138138
}
139139

Diff for: src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueApiTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private function prepareHeadersAndTags(Headers $headers): array
161161

162162
continue;
163163
}
164-
$headersAndTags['headers'][$name] = $header->getBodyAsString();
164+
$headersAndTags['headers'][$header->getName()] = $header->getBodyAsString();
165165
}
166166

167167
return $headersAndTags;

Diff for: src/Symfony/Component/Mailer/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
6.1
55
---
66

7-
* Make `start()` and `stop()` methods public on `SmtpTransport`
7+
* Make `start()` and `stop()` methods public on `SmtpTransport`
88

99
6.0
1010
---

Diff for: src/Symfony/Component/Security/Core/Authentication/RememberMe/CacheTokenVerifier.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ public function verifyToken(PersistentTokenInterface $token, string $tokenValue)
4545
}
4646

4747
$cacheKey = $this->getCacheKey($token);
48-
if (!$this->cache->hasItem($cacheKey)) {
48+
$item = $this->cache->getItem($cacheKey);
49+
if (!$item->isHit()) {
4950
return false;
5051
}
5152

52-
$item = $this->cache->getItem($cacheKey);
5353
$outdatedToken = $item->get();
5454

5555
return hash_equals($outdatedToken, $tokenValue);

0 commit comments

Comments
 (0)