WebAuthn | Registrazione

La Registrazione WebAuthn coinvolge il client (browser), l'authenticator (dispositivo di sicurezza) e il relying party (RP; il server delphi/cbuilder TsgcWSAPIServer_WebAuthn).

 

Opzioni di Registrazione

 

La creazione di una nuova credenziale utente richiede solitamente che il client avvii il flusso di registrazione utilizzando una nuova richiesta HTTP all'endpoint Registration Options configurato nel server TsgcWSAPIServer_WebAuthn. Per impostazione predefinita, l'endpoint è /sgcWebAuthn/Registration/Options, quindi se il Suo server è in ascolto sul dominio https://www.test.com, il client dovrebbe effettuare una nuova richiesta all'url https://www.test.com/sgcWebAuthn/Registration/Options.

 

Il client invia una nuova richiesta passando come payload il seguente json (usando test come nome utente)

 

{"username":"test","algorithms":[]}

 

Il server legge la richiesta e restituisce una risposta con una nuova sfida.

 

{
"rp": {
"name": "localhost",
"id": "localhost"
},
"user": {
"id": "36b9d6a84204487382fee62e7e67a80d",
"name": "test",
"displayName": "test"
},
"challenge": "6c6c468c99f24bf29a85a15b661f75f385654f97309c46bab2909c926e17ccbe",
"pubKeyCredParams": [
{
"type": "public-key",
"alg": "-7"
},
{
"type": "public-key",
"alg": "-257"
}
],
"timeout": 60000,
"excludeCredentials": [],
"authenticatorSelection": {
"residentKey": "preferred",
"requireResidentKey": false,
"userVerification": "preferred"
},
"attestation": "direct",
"hints": [],
"extensions": {
"credProps": true
}
}

 

La risposta restituisce i seguenti dati:

 

 

 

Verifica registrazione

 

Ora il client ha la risposta dal server, legge la risposta e l'authenticator restituisce i dati crittografici al web-browser del client. Ora il client invia una nuova HTTP Request con i seguenti dati al Registration Verify Endpoint configurato nel server TsgcWSAPIServer_WebAuthn, che per impostazione predefinita è /sgcWebAuthn/Registration/Verify

, quindi se il Suo server è in ascolto nel dominio https://www.test.com, il client dovrebbe effettuare una nuova richiesta all'url https://www.test.com/sgcWebAuthn/Registration/Verify.

 

L'autenticatore risponde al JavaScript nel browser con:

 

 

Di seguito è riportato un esempio:

 

{
"id": "yeA4BVRlrAfLG-KzqsL_rlI4ffhuKHK8uoEkVoab065UkS82Zqlh9VFQHIYwOuOo",
"rawId": "yeA4BVRlrAfLG-KzqsL_rlI4ffhuKHK8uoEkVoab065UkS82Zqlh9VFQHIYwOuOo",
"response": {
"attestationObject": "o2NmbXRmcGFja2VkZ2F0dFN0....",
"clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3Jl....",
"transports": [
"nfc",
"usb"
],
"publicKeyAlgorithm": -7,
"publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj....",
"authenticatorData": "SZYN5YgOjGh0NBcPZHZgW4_k...."
},
"type": "public-key",
"clientExtensionResults": {
"credProps": {
"rk": true
}
},
"authenticatorAttachment": "cross-platform"
}

 

Il server legge la richiesta JSON dal client e decodifica, verifica e memorizza la chiave pubblica e l'ID credenziale.

 

Decodifica attestationObject e clientDataJSON:

 

 

Store Credential:

 

 

 

 

Flusso di Registrazione

Ottenga maggiori informazioni sul processo di Registration Flow utilizzando i seguenti link: