Skip to content

Commit d2c4bef

Browse files
authored
Add authenticator selection criteria to GeneratePasskeyRegisterOptions
This aligns the selection criteria with documentation to allow the passkey to be "discovered". Per https://simplewebauthn.dev/docs/advanced/passkeys#server, these must be set: // "Discoverable credentials" used to be called "resident keys". The // old name persists in the options passed to `navigator.credentials.create()`. residentKey: 'required', userVerification: 'preferred',
1 parent c1c357d commit d2c4bef

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Actions/GeneratePasskeyRegisterOptionsAction.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public function execute(
2020
rp: $this->relatedPartyEntity(),
2121
user: $this->generateUserEntity($authenticatable),
2222
challenge: $this->challenge(),
23+
authenticatorSelection: $this->authenticatorSelection(),
24+
attestation: PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE,
2325
);
2426

2527
if ($asJson) {
@@ -51,4 +53,14 @@ protected function challenge(): string
5153
{
5254
return Str::random();
5355
}
56+
57+
58+
public function authenticatorSelection(): AuthenticatorSelectionCriteria
59+
{
60+
return new AuthenticatorSelectionCriteria(
61+
null,
62+
AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_PREFERRED,
63+
AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_REQUIRED,
64+
);
65+
}
5466
}

0 commit comments

Comments
 (0)