Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit c937e5f

Browse files
[Security/Http] fix parsing X509 emailAddress
1 parent 94a07e6 commit c937e5f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Http/Firewall/X509AuthenticationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function getPreAuthenticatedData(Request $request)
4646
$user = $request->server->get($this->userKey);
4747
} elseif (
4848
$request->server->has($this->credentialKey)
49-
&& preg_match('#emailAddress=(.+\@.+\.[^,/]+)($|,|/)#', $request->server->get($this->credentialKey), $matches)
49+
&& preg_match('#emailAddress=([^,/@]++@[^,/]++)#', $request->server->get($this->credentialKey), $matches)
5050
) {
5151
$user = $matches[1];
5252
}

Http/Tests/Firewall/X509AuthenticationListenerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public static function dataProviderGetPreAuthenticatedDataNoUser()
8181
yield ['cert+something@example.com', 'CN=Sample certificate DN,emailAddress=cert+something@example.com'];
8282
yield ['cert+something@example.com', 'emailAddress=cert+something@example.com,CN=Sample certificate DN'];
8383
yield ['cert+something@example.com', 'emailAddress=cert+something@example.com'];
84+
yield ['firstname.lastname@mycompany.co.uk', 'emailAddress=firstname.lastname@mycompany.co.uk,CN=Firstname.Lastname,OU=london,OU=company design and engineering,OU=Issuer London,OU=Roaming,OU=Interactive,OU=Users,OU=Standard,OU=Business,DC=england,DC=core,DC=company,DC=co,DC=uk'];
8485
}
8586

8687
public function testGetPreAuthenticatedDataNoData()

0 commit comments

Comments
 (0)