Skip to main content

Complete WebAuthn Registration

Complete WebAuthn registration by verifying attestation and storing credential.

Quick Navigation

Endpoint

POST /api/v1/webauthn/register/complete

Headers

HeaderRequiredDescription
AuthorizationYesBearer <access_token>
Content-TypeYesapplication/json

Request Body

{
"credential": {
"id": "credential_id_base64",
"rawId": "credential_raw_id_base64",
"response": {
"attestationObject": "attestation_object_cbor",
"clientDataJSON": "client_data_json"
},
"type": "public-key"
},
"device_name": "iPhone 14 Pro"
}

Parameters

FieldTypeRequiredDescription
credentialobjectYesWebAuthn credential from browser API
device_namestringYesDevice name from registration start

Response

Success (200)

{
"success": true,
"data": {
"credential_id": 123,
"device_name": "iPhone 14 Pro",
"created_at": "2024-01-01T12:00:00Z",
"message": "WebAuthn credential registered successfully"
},
"message": "WebAuthn credential registered successfully"
}

Error Codes

StatusCodeDescription
400REGISTRATION_COMPLETION_FAILEDRegistration completion failed
400INVALID_ATTESTATIONInvalid attestation
401UNAUTHORIZEDInvalid or missing token
404USER_NOT_FOUNDUser not found
404CHALLENGE_NOT_FOUNDRegistration challenge not found or expired

Data Flow

  1. Authentication

    • Verify access token
    • Get current user
  2. Challenge Verification

    • Retrieve challenge from Redis
    • Verify challenge matches
    • Verify challenge not expired
  3. Attestation Verification

    • Parse attestation object
    • Verify attestation signature
    • Verify client data
    • Extract public key
  4. Credential Storage

    • Store credential in database
    • Store public key
    • Link credential to user
    • Store device name
  5. Challenge Cleanup

    • Remove challenge from Redis
  6. Audit Logging

    • Log credential registration
    • Record device name
  7. Response

    • Return credential details

Features

  • Verify attestation
  • Store credential securely
  • Enable WebAuthn for user
  • Support for multiple credentials per user
  • Device name association

Example

curl -X POST https://api.rivergen.com/api/v1/webauthn/register/complete \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"credential": {...},
"device_name": "iPhone 14 Pro"
}'