Код: Выделить всё
return [
'challenge' => $challengeBase64,
'rp' => [
'name' => Yii::$app->name,
'id' => 'x-y-z.ngrok-free.app',
],
'user' => [
'id' => $userId,
'name' => $displayName,
'displayName' => $displayName,
],
'pubKeyCredParams' => [
['type' => 'public-key', 'alg' => -7],
['type' => 'public-key', 'alg' => -257],
],
'authenticatorSelection' => [
'authenticatorAttachment' => 'cross-platform',
'requireResidentKey' => false,
'userVerification' => 'discouraged',
],
'timeout' => 60000,
'attestation' => 'direct',
'transports' => ['usb'],
];
< /code>
В регистрационном представлении: < /p>
try {
// get challenge
let challengeResponse = await fetch('/user/challenge');
if (!challengeResponse.ok) {
throw new Error('Failed to get challenge from server');
}
let challengeData = await challengeResponse.json();
const attResp = await SimpleWebAuthnBrowser.startRegistration(challengeData);
// // get credential data
let credential_id = attResp.rawId;
let public_key = attResp.response.publicKey;
let sign_count = 0;
let transports = attResp.response.transports ? attResp.response.transports : [];
let attestation_type = attResp.type;
.....
Код: Выделить всё
NotAllowedError: The operation either timed out or was not allowed. See: https://www.w3.org/TR/webauthn-2/#sctn-privacy-considerations-client.
< /code>
Вот мой код в представлении и возврат из задачи.try {
const response = await fetch('/user/another-challenge', { method: 'GET' });
const options = await response.json();
const assertion = await SimpleWebAuthnBrowser.startAuthentication(options); // gives an error above
return [
'challenge' => Base64Url::encode($challenge),
'rp' => [
'name' => Yii::$app->name,
'id' => 'x-y-z.ngrok-free.app',
],
'user' => [
'id' => Base64Url::encode($user->id),
'name' => $user->username,
'displayName' => $user->username,
],
'allowCredentials' => [
[
'type' => 'public-key',
'id' => Base64Url::encode($credential->credential_id),
'transports' => ['usb'],
]
],
'timeout' => 60000,
'userVerification' => 'discouraged',
];
< /code>
Я задаюсь вопросом, имеет ли это какое -то отношение к ответу на задачу регистрации (с фазы регистрации). < /p>
Любая подсказка или руководство будет оценено. Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/795 ... thnbrowser
Мобильная версия