WebAuthn Registrazione | Risposta

Il server risponde alla richiesta di opzioni di registrazione del client (ad esempio, POST /sgcWebAuthn/Registration/Options) con un payload JSON simile al seguente (dopo la codifica base64url dei campi binari):

 

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

 

 

Di seguito è riportata una descrizione dei campi:

 

 

Prima che la risposta venga inviata al client, viene chiamato l'evento OnWebAuthnRegistrationOptionsResponse, che Le consente di personalizzare la risposta.

 


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;