if (assertion == null || assertion.Id == null || assertion.AuthenticatorData == null || assertion.ClientDataJSON == null || assertion.Signature == null)
{
// **assertion.UserHandle is null for Samsung phone**
return FAIL_STATUS;
}
Действительно ли мой комментарий «assertion.UserHandle имеет значение null для телефона Samsung»? Я тестирую только http://localhost на своем телефоне Samsung.
Если это правда, то как мне надежно связать пользователя веб-сайта с его PassKey в моей базе данных? Использовать/хранить идентификатор утверждения рядом с моим пользователем в БД? Но, конечно же, это исключит возможность обнаружения учетных данных для любого, у кого есть телефон Samsung
Невозможность вернуть дескриптор пользователя касается только метода navigator.credentials.get()?
return navigator.credentials.get({
publicKey: getAssertionOptions
}).then(rawAssertion => {
var assertion = {
id: base64encode(rawAssertion.rawId),
clientDataJSON: arrayBufferToString(rawAssertion.response.clientDataJSON),
userHandle: base64encode(rawAssertion.response.userHandle),
signature: base64encode(rawAssertion.response.signature),
authenticatorData: base64encode(rawAssertion.response.authenticatorData)
};
Ключ был создан с помощью: -
var createCredentialOptions = {
rp: {
name: "WebAuthn Sample App",
icon: ""
},
user: {
id: stringToArrayBuffer("some.user.guid"),
name: "maherrj@gmail.com",
displayName: "Richard Maher",
icon: ""
},
pubKeyCredParams: [
{
//External authenticators support the ES256 algorithm
type: "public-key",
alg: -7
},
{
//Windows Hello supports the RS256 algorithm
type: "public-key",
alg: -257
}
],
authenticatorSelection: {
//Select authenticators that support username-less flows
requireResidentKey: true,
userVerification: "discouraged",
authenticatorAttachment: "cross-platform",
},
//Since Edge shows UI, it is better to select larger timeout values
timeout: 30000,
//an opaque challenge that the authenticator signs over
challenge: stringToArrayBuffer(serverChallenge.Token),
//prevent re-registration by specifying existing credentials here
excludeCredentials: [],
//specifies whether you need an attestation statement
attestation: "none"
};
const authAbort = new AbortController();
const abortSignal = authAbort.signal;
abortSignal.addEventListener("abort", (e) => { console.log("It has been aborted"); });
return navigator.credentials.create({
publicKey: createCredentialOptions,
signal: abortSignal
}).then(rawAttestation => {
var attestation = {
id: base64encode(rawAttestation.rawId),
clientDataJSON: arrayBufferToString(rawAttestation.response.clientDataJSON),
attestationObject: base64encode(rawAttestation.response.attestationObject)
};
console.log("=== Attestation response ===");
logVariable("id (base64)", attestation.id);
logVariable("clientDataJSON", attestation.clientDataJSON);
logVariable("attestationObject (base64)", attestation.attestationObject);
verifyCredentials(attestation).then(
result => {
var res = JSON.parse(result);
console.log(res.success);
if (res.success) {
localStorage.setItem("credentialId", res.id);
}
});
return;
}).catch(
(err)=>{
if (err.name == "NotAllowedError") {
console.log("here " + err.name);
} else {
console.log("other " + err.name);
}
return Promise.resolve(false);
});
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... lways-null
Мобильная версия