Skip to content

Commit

Permalink
bug #31407 [Security] added support for updated "distinguished name" …
Browse files Browse the repository at this point in the history
…format in x509 authentication (Robert Kopera)

This PR was submitted for the master branch but it was squashed and merged into the 3.4 branch instead (closes #31407).

Discussion
----------

[Security] added support for updated "distinguished name" format in x509 authentication

RFC 2253 (https://tools.ietf.org/html/rfc2253)
issue: #31406

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31406
| License       | MIT
| Doc PR        |

Commits
-------

bdbac2c [Security] added support for updated \"distinguished name\" format in x509 authentication
  • Loading branch information
fabpot committed Jun 4, 2019
2 parents 0797ef2 + bdbac2c commit 5498cf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Expand Up @@ -44,7 +44,10 @@ protected function getPreAuthenticatedData(Request $request)
$user = null;
if ($request->server->has($this->userKey)) {
$user = $request->server->get($this->userKey);
} elseif ($request->server->has($this->credentialKey) && preg_match('#/emailAddress=(.+\@.+\..+)(/|$)#', $request->server->get($this->credentialKey), $matches)) {
} elseif (
$request->server->has($this->credentialKey)
&& preg_match('#emailAddress=(.+\@.+\.[^,/]+)($|,|/)#', $request->server->get($this->credentialKey), $matches)
) {
$user = $matches[1];
}

Expand Down
Expand Up @@ -56,9 +56,8 @@ public static function dataProviderGetPreAuthenticatedData()
/**
* @dataProvider dataProviderGetPreAuthenticatedDataNoUser
*/
public function testGetPreAuthenticatedDataNoUser($emailAddress)
public function testGetPreAuthenticatedDataNoUser($emailAddress, $credentials)
{
$credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress;
$request = new Request([], [], [], [], [], ['SSL_CLIENT_S_DN' => $credentials]);

$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
Expand All @@ -76,10 +75,12 @@ public function testGetPreAuthenticatedDataNoUser($emailAddress)

public static function dataProviderGetPreAuthenticatedDataNoUser()
{
return [
'basicEmailAddress' => ['cert@example.com'],
'emailAddressWithPlusSign' => ['cert+something@example.com'],
];
yield ['cert@example.com', 'CN=Sample certificate DN/emailAddress=cert@example.com'];
yield ['cert+something@example.com', 'CN=Sample certificate DN/emailAddress=cert+something@example.com'];
yield ['cert@example.com', 'CN=Sample certificate DN,emailAddress=cert@example.com'];
yield ['cert+something@example.com', 'CN=Sample certificate DN,emailAddress=cert+something@example.com'];
yield ['cert+something@example.com', 'emailAddress=cert+something@example.com,CN=Sample certificate DN'];
yield ['cert+something@example.com', 'emailAddress=cert+something@example.com'];
}

/**
Expand Down

0 comments on commit 5498cf5

Please sign in to comment.