Skip to content

Commit 690573b

Browse files
alcaeusfabpot
authored andcommitted
Fixed incompatibility of x509 auth with nginx
1 parent 77124af commit 690573b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Firewall/X509AuthenticationListener.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@ public function __construct(SecurityContextInterface $securityContext, Authentic
4141
*/
4242
protected function getPreAuthenticatedData(Request $request)
4343
{
44-
if (!$request->server->has($this->userKey)) {
45-
throw new BadCredentialsException(sprintf('SSL key was not found: %s', $this->userKey));
44+
$user = null;
45+
if ($request->server->has($this->userKey)) {
46+
$user = $request->server->get($this->userKey);
47+
} elseif ($request->server->has($this->credentialKey) && preg_match('#/emailAddress=(.+\@.+\..+)(/|$)#', $request->server->get($this->credentialKey), $matches)) {
48+
$user = $matches[1];
4649
}
4750

48-
return array($request->server->get($this->userKey), $request->server->get($this->credentialKey, ''));
51+
if (null === $user) {
52+
throw new BadCredentialsException(sprintf('SSL credentials not found: %s, %s', $this->userKey, $this->credentialKey));
53+
}
54+
55+
return array($user, $request->server->get($this->credentialKey, ''));
4956
}
5057
}

0 commit comments

Comments
 (0)