Authentication without username
With Webauthn, it is possible to authenticate a user without username. This behavior implies several constraints:
    1.
    During the registration of the authenticator, a Resident Key must have been asked,
    2.
    The user verification is required,
    3.
    The list of allowed authenticators must be empty
In case of failure, you should continue with the standard authentication process i.e. by asking the username of the user.

The Easy Way

Selection criteria for the registration of the authenticator:
1
use Webauthn\AuthenticatorSelectionCriteria;
2
use Webauthn\PublicKeyCredentialCreationOptions;
3
4
$authenticatorSelectionCriteria = new AuthenticatorSelectionCriteria(
5
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE,
6
true, // Resident key required
7
AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_REQUIRED // User verification required
8
);
Copied!
The Request Options:
1
<?php
2
3
use Webauthn\PublicKeyCredentialRequestOptions;
4
5
$ublicKeyCredentialRequestOptions = $server->generatePublicKeyCredentialRequestOptions(
6
PublicKeyCredentialRequestOptions::USER_VERIFICATION_REQUIREMENT_REQUIRED,
7
);
Copied!

The Hard Way

Selection criteria for the registration of the authenticator:
1
$authenticatorSelectionCriteria = new AuthenticatorSelectionCriteria(
2
AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE,
3
true, // Resident key required
4
AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_REQUIRED // User verification required
5
);
6
7
$publicKeyCredentialCreationOptions = new PublicKeyCredentialCreationOptions(
8
$rpEntity,
9
$userEntity,
10
$challenge,
11
$publicKeyCredentialParametersList,
12
$timeout,
13
$excludedPublicKeyDescriptors,
14
$authenticatorSelectionCriteria
15
);
Copied!
The Request Options:
1
// Public Key Credential Request Options
2
$publicKeyCredentialRequestOptions = new PublicKeyCredentialRequestOptions(
3
random_bytes(32),
4
60000,
5
'foo.example.com',
6
[],
7
PublicKeyCredentialRequestOptions::USER_VERIFICATION_REQUIREMENT_REQUIRED
8
);
Copied!

The Symfony Way

The bundle configuration should have a profile with the constraints listed above:
1
webauthn:
2
credential_repository: '…'
3
user_repository: '…'
4
creation_profiles:
5
default:
6
rp:
7
name: 'My application'
8
id: 'example.com'
9
authenticator_selection_criteria:
10
require_resident_key: true
11
user_verification: !php/const Webauthn\AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_REQUIRED
12
request_profiles:
13
default:
14
rp_id: 'example.com'
15
user_verification: !php/const Webauthn\AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_REQUIRED
Copied!
Last modified 1d ago
Export as PDF
Copy link