WebAuthn 注册 | 请求

此注册选项请求对于安全引导 WebAuthn 注册至关重要。它要求服务器:

 

 

浏览器必须从服务器获取凭据创建选项以启动安全的 WebAuthn 凭据注册。这通常通过从浏览器向服务器端点(例如 /sgcWebAuthn/Registration/Options)发出 HTTPS POST 请求来完成,该请求会准备挑战、RP ID 和用户信息等参数。

 

请求体包含标识用户的数据,可能还包含配置偏好设置。通常格式如下:

 

{
"username": "alice@example.com",
"displayName": "Alice Smith",
"authenticatorSelection": {
"authenticatorAttachment": "platform", // optional: platform or cross-platform
"userVerification": "preferred" // optional: required | preferred | discouraged
},
"attestation": "none", // or "direct", "indirect"
"residentKey": "discouraged" // optional
}

 

WebAuthn 服务器组件在 EndpointOptions.RegistrationOptions 属性配置的端点上监听,处理浏览器获取 PublicKeyCredentialCreationOptions 的初始请求。当服务器收到新的 HTTP 请求时,会调用事件 OnWebAuthnRegistrationOptionsRequest,您可以访问客户端发送的请求,并通过将 Accept 参数设置为 False 来取消请求。

 


procedure OnWebAuthnRegistrationOptionsRequest(Sender: TObject; const aRequest: TsgcWebAuthn_RegistrationOptions_Request; var Accept: Boolean);
begin
  if aRequest.Username = 'anonymous' then
    Accept := False;
end;