WebAuthn 注册 | 响应

服务器响应客户端的注册选项请求(例如 POST /sgcWebAuthn/Registration/Options),返回如下所示的 JSON 载荷(二进制字段经过 base64url 编码):

 

{
"publicKey": {
"rp": {
"name": "esegece software",
"id": "esegece.com"
},
"user": {
"id": "c3ViamVjdC1pZA", // base64url-encoded ArrayBuffer (user handle)
"name": "webauthn@esegece.com",
"displayName": "Delphi Developer"
},
"challenge": "Xz8x2K6nY3gZ...", // base64url-encoded challenge
"pubKeyCredParams": [
{ "type": "public-key", "alg": -7 }, // ES256
{ "type": "public-key", "alg": -257 } // RS256
],
"timeout": 60000,
"attestation": "none",
"authenticatorSelection": {
"authenticatorAttachment": "platform",
"userVerification": "preferred",
"residentKey": "discouraged"
}
}
}

 

 

以下是字段说明:

 

 

在响应发送给客户端之前,将调用事件 OnWebAuthnRegistrationOptionsResponse,允许您自定义响应。

 


procedure OnWebAuthnRegistrationOptionsResponse(Sender: TObject; const aRequest: TsgcWebAuthn_RegistrationOptions_Request; const aResponse: TsgcWebAuthn_RegistrationOptions_Response);
begin
  if aRequest.Username = 'esegece.com' then
  begin
    aResponse.ExcludeCredentials.AddCredentialRecordFromJSON('json1.txt');
    aResponse.ExcludeCredentials.AddCredentialRecordFromJSON('json2.txt');
  end;
end;