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

View file

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