From 7a95f205900b9e75976208d759d265859764dcfc Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Thu, 21 Sep 2023 16:25:21 +1200 Subject: [PATCH 1/2] FIX Pass AuthenticatorSelectionCriteria as argument to PublicKeyCredentialCreationOptions constructor --- src/RegisterHandler.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/RegisterHandler.php b/src/RegisterHandler.php index 859f9cb..97c566d 100644 --- a/src/RegisterHandler.php +++ b/src/RegisterHandler.php @@ -259,7 +259,7 @@ protected function getCredentialCreationOptions( $this->getUserEntity($store->getMember()), random_bytes(32), [new PublicKeyCredentialParameters('public-key', Algorithms::COSE_ALGORITHM_ES256)], - 40000 + $this->getAuthenticatorSelectionCriteria() ); $credentialOptions->setAuthenticatorSelection($this->getAuthenticatorSelectionCriteria()); $credentialOptions->setAttestation(PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE); @@ -282,7 +282,6 @@ protected function getCredentialCreationOptions( */ protected function getAuthenticatorSelectionCriteria(): AuthenticatorSelectionCriteria { - return AuthenticatorSelectionCriteria::create() - ->setAuthenticatorAttachment((string) $this->config()->get('authenticator_attachment')); + return AuthenticatorSelectionCriteria::create((string) $this->config()->get('authenticator_attachment')); } } From 0075e3fc92f473c4c4b9315af63fa5c49b379c0d Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Thu, 21 Sep 2023 16:46:40 +1200 Subject: [PATCH 2/2] FIX Argument rpId must be of type string --- src/RegisterHandler.php | 4 +++- src/VerifyHandler.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/RegisterHandler.php b/src/RegisterHandler.php index 97c566d..64f2f50 100644 --- a/src/RegisterHandler.php +++ b/src/RegisterHandler.php @@ -261,6 +261,7 @@ protected function getCredentialCreationOptions( [new PublicKeyCredentialParameters('public-key', Algorithms::COSE_ALGORITHM_ES256)], $this->getAuthenticatorSelectionCriteria() ); + $credentialOptions->setTimeout(40000); $credentialOptions->setAuthenticatorSelection($this->getAuthenticatorSelectionCriteria()); $credentialOptions->setAttestation(PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE); @@ -282,6 +283,7 @@ protected function getCredentialCreationOptions( */ protected function getAuthenticatorSelectionCriteria(): AuthenticatorSelectionCriteria { - return AuthenticatorSelectionCriteria::create((string) $this->config()->get('authenticator_attachment')); + return AuthenticatorSelectionCriteria::create() + ->setAuthenticatorAttachment((string) $this->config()->get('authenticator_attachment')); } } diff --git a/src/VerifyHandler.php b/src/VerifyHandler.php index 651131c..218750c 100644 --- a/src/VerifyHandler.php +++ b/src/VerifyHandler.php @@ -185,7 +185,8 @@ protected function getCredentialRequestOptions( return $source->getPublicKeyCredentialDescriptor(); }, $validCredentials ?? []); - $options = new PublicKeyCredentialRequestOptions(random_bytes(32), 40000); + $options = new PublicKeyCredentialRequestOptions((string) random_bytes(32)); + $options->setTimeout(40000); $options->allowCredentials(...$descriptors); $options->setUserVerification(PublicKeyCredentialRequestOptions::USER_VERIFICATION_REQUIREMENT_PREFERRED);