Skip to content

Biometric Authentication — Fingerprint and Face Authentication Integration

DodaTech Updated 2026-06-28 1 min read

In this tutorial, you'll learn about Biometric Authentication. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Biometric authentication uses unique physical characteristics for user verification, typically as an additional factor or passkey alternative.

// WebAuthn browser registration
async function registerBiometric() {
  const publicKeyCredential = await navigator.credentials.create({
    publicKey: {
      challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
      rp: { name: 'ScanApp', id: 'scanapp.example.com' },
      user: {
        id: Uint8Array.from(userId, c => c.charCodeAt(0)),
        name: 'user@example.com',
        displayName: 'User Name'
      },
      pubKeyCredParams: [
        { type: 'public-key', alg: -7 },
        { type: 'public-key', alg: -257 }
      ],
      authenticatorSelection: {
        authenticatorAttachment: 'platform',
        residentKey: 'preferred',
        userVerification: 'required'
      },
      attestation: 'direct',
      timeout: 60000
    }
  });

  return {
    id: publicKeyCredential.id,
    rawId: base64url(publicKeyCredential.rawId),
    type: publicKeyCredential.type,
    response: {
      clientDataJSON: base64url(publicKeyCredential.response.clientDataJSON),
      attestationObject: base64url(publicKeyCredential.response.attestationObject)
    }
  };
}

// Biometric authentication
async function authenticateWithBiometric() {
  const assertion = await navigator.credentials.get({
    publicKey: {
      challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
      allowCredentials: credentials.map(cred => ({
        id: base64url.decode(cred.id),
        type: 'public-key'
      })),
      userVerification: 'required',
      timeout: 60000
    }
  });

  // Send to server for verification
  return fetch('/auth/webauthn/verify', {
    method: 'POST',
    body: JSON.stringify({ assertion })
  });
}

Biometric authentication provides phishing-resistant, frictionless authentication on devices with biometric sensors.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro