Understanding biometrics

Tutorial 3 of 5

Understanding Biometrics

1. Introduction

In this tutorial, we will delve into the world of biometrics and how it's used in web applications to provide security.

Goals:
- Understand what biometrics is and how it works.
- Know the different types of biometrics.
- Implement basic biometric authentication in a web application.

What You'll Learn:
- The key concepts and principles of biometrics.
- How to use biometric data for authentication.
- Best practices for handling biometric data.

Prerequisites:
- Basic knowledge of web development.
- Familiarity with JavaScript.

2. Step-by-Step Guide

Biometrics

Biometrics refers to metrics related to human characteristics. Biometrics authentication is used in computer science as a form of identification and access control.

Types of Biometrics

There are two categories of biometrics:
- Physiological are related to the shape of the body. Examples include, but are not limited to fingerprint, face recognition, DNA, palm print, hand geometry, iris recognition, etc.
- Behavioral are related to the behavior of a person. Examples include, but are not limited to typing rhythm, gait, and voice.

Using Biometrics in Web Applications

You can use the Web Authentication API in JavaScript for biometric authentication. It's a web standard for the public key authentication of users. It allows servers to register and authenticate users using public key cryptography instead of a password.

3. Code Examples

Example: Using the Web Authentication API

// Create a new credential
navigator.credentials.create({
  publicKey: {
    // Random or user specified challenge
    challenge: new Uint8Array([/* bytes sent from the server */]),
    rp: {
      name: "Example Corp",
    },
    user: {
      id: new Uint8Array(16),
      name: "jdoe@example.com",
      displayName: "John Doe",
    },
    pubKeyCredParams: [{
      type: "public-key",
      alg: -7,  // "ES256" IANA COSE Algorithms registry
    }],
  },
});

In the above example, we create a new credential. This is usually done during registration.

// Request an assertion
navigator.credentials.get({
  publicKey: {
    challenge: new Uint8Array([/* bytes sent from the server */]),
    allowCredentials: [{
      type: "public-key",
      id: new Uint8Array([/* bytes sent from the server */]),
    }],
  },
});

The above example requests an assertion. This is usually done during login.

4. Summary

We've learned about biometrics and how it's used in web applications for security. We've also learned how to use the Web Authentication API in JavaScript for biometric authentication.

For further learning, you might want to delve more into the Web Authentication API and how to handle errors. Here are some resources:
- Web Authentication API on MDN
- Web Authentication: An API for accessing Public Key Credentials

5. Practice Exercises

  • Exercise 1: Create a web application that uses biometric authentication for login. Use the Web Authentication API.
  • Exercise 2: Add error handling to the application you created in Exercise 1.
  • Exercise 3: Add a registration feature to the application, where users can create a new credential.

Tips for Further Practice
Keep experimenting with the Web Authentication API, trying out different options and configurations. You might also want to practice with different types of biometrics, such as face recognition or voice recognition.