Fix authentication request creation

This commit is contained in:
Dane Everitt 2022-02-13 14:23:20 -05:00
parent 969d40d6c1
commit 54c7207836
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 11 additions and 13 deletions

View file

@ -75,7 +75,7 @@ class LoginController extends AbstractLoginController
return; return;
} }
if (!$user->use_totp && empty($user->security_keys_count)) { if (!$user->use_totp && empty($user->securityKeys)) {
return $this->sendLoginResponse($user, $request); return $this->sendLoginResponse($user, $request);
} }
@ -88,21 +88,19 @@ class LoginController extends AbstractLoginController
$response = [ $response = [
'complete' => false, 'complete' => false,
'methods' => array_filter([ 'methods' => array_values(array_filter([
$user->use_totp ? self::METHOD_TOTP : null, $user->use_totp ? self::METHOD_TOTP : null,
$user->security_keys_count > 0 ? self::METHOD_WEBAUTHN : null, !empty($user->securityKeys) ? self::METHOD_WEBAUTHN : null,
]), ])),
'confirmation_token' => $token, 'confirmation_token' => $token,
]; ];
if ($user->security_keys_count > 0) { if (!empty($user->securityKeys)) {
// $key = $this->service->handle($user); $key = $this->service->handle($user);
//
// $request->session()->put(self::SESSION_PUBLICKEY_REQUEST, $publicKey); $request->session()->put(self::SESSION_PUBLICKEY_REQUEST, $key);
//
// $response['webauthn'] = [ $response['webauthn'] = ['public_key' => $key];
// 'public_key' => $publicKey,
// ];
} }
return new JsonResponse($response); return new JsonResponse($response);

View file

@ -27,7 +27,7 @@ class GeneratePublicKeyCredentialsRequestService
{ {
$credentials = $user->securityKeys->map(function (SecurityKey $key) { $credentials = $user->securityKeys->map(function (SecurityKey $key) {
return $key->getPublicKeyCredentialDescriptor(); return $key->getPublicKeyCredentialDescriptor();
}); })->values()->toArray();
$response = $this->serverRepository->getServer($user) $response = $this->serverRepository->getServer($user)
->generatePublicKeyCredentialRequestOptions( ->generatePublicKeyCredentialRequestOptions(