# kanidm/webauthn-rs architecture

> Architecture diagram of the GitHub repository kanidm/webauthn-rs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kanidm/webauthn-rs
- Repository: https://github.com/kanidm/webauthn-rs

## Overview

##### Main Components

a. Core Components:
- Webauthn-RS (Main API Layer)
- Webauthn-RS-Core (Protocol Implementation)
- Webauthn-RS-Proto (Protocol Bindings)
- FIDO-MDS (Authenticator Metadata Service)

b. External Components:
- Web Browsers/Clients
- Hardware Authenticators
- Application Servers

##### Component Relationships

**[Client Layer]**
- Web Browsers
- Hardware Authenticators (USB/NFC/Bluetooth)

**[Integration Layer]**
- Tutorial Implementations (Actix/Axum/Tide)
- WebAuthn-RS API

**[Core Processing Layer]**
- WebAuthn-RS-Core
- WebAuthn-RS-Proto

**[Support Services]**
- FIDO-MDS
- Device Catalog
- Attestation CA

##### Key Elements to Highlight

a. Authentication Flow:
- Registration path
- Authentication path
- Attestation verification flow

b. Security Boundaries:
- Client-side security context
- Server-side security context
- Hardware security boundaries

##### Implementation Details

a. Core Libraries:
**[webauthn-rs]**
- ↑
**[webauthn-rs-core]**
- ↑
**[webauthn-rs-proto]**

b. Transport Layers:
- USB (fido-hid-rs)
- NFC
- Bluetooth
- Cable tunnel server

c. Support Services:
- Device catalog
- Attestation CA
- FIDO MDS integration

##### Additional Notes

- Notes about security boundaries and trust relationships
- Optional components (like the compatibility tester) in a different style
- Version/compatibility information for supported authenticators

##### Implementation Patterns

- The modular architecture allowing different transport mechanisms
- The separation of concerns between protocol and implementation
- The security-first approach with enforced constraints
- The extensibility points for different web frameworks

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL["Client Layer"]
        WB[Web Browsers]
        HA[Hardware Authenticators]
    end

    %% Integration Layer
    subgraph IL["Integration Layer"]
        TI["Tutorial Implementations"]:::tutorial
        WA["Webauthn-RS API"]:::api
    end

    %% Core Processing Layer
    subgraph CPL["Core Processing Layer"]
        WC["Webauthn-RS-Core"]:::core
        WP["Webauthn-RS-Proto"]:::proto
    end

    %% Transport Layer
    subgraph TL["Transport Layer"]
        USB["USB Transport"]:::transport
        NFC["NFC Transport"]:::transport
        BT["Bluetooth Transport"]:::transport
        CTS["Cable Tunnel Server"]:::transport
        FHID["FIDO HID Implementation"]:::transport
        AI["Authenticator Implementation"]:::transport
    end

    %% Support Services
    subgraph SS["Support Services"]
        FMDS["FIDO-MDS"]:::support
        DC["Device Catalog"]:::support
        ACA["Attestation CA"]:::support
        CT["Compatibility Tester"]:::support
    end

    %% Relationships
    WB --> TI
    WB --> WA
    HA --> USB
    HA --> NFC
    HA --> BT
    HA --> CTS

    TI --> WA
    WA --> WC
    WC --> WP

    USB --> FHID
    NFC --> AI
    BT --> AI
    CTS --> AI

    WC --> FMDS
    WC --> DC
    WC --> ACA
    WC --> CT

    %% Styles
    classDef api fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#1976D2,stroke:#0D47A1,color:white
    classDef proto fill:#0D47A1,stroke:#052A60,color:white
    classDef transport fill:#4CAF50,stroke:#2E7D32,color:white
    classDef support fill:#FFC107,stroke:#FFA000,color:black
    classDef tutorial fill:#9E9E9E,stroke:#616161,color:white

    %% Click Events
    click WA "https://github.com/kanidm/webauthn-rs/tree/master/webauthn-rs/"
    click WC "https://github.com/kanidm/webauthn-rs/tree/master/webauthn-rs-core/"
    click WP "https://github.com/kanidm/webauthn-rs/tree/master/webauthn-rs-proto/"
    click FMDS "https://github.com/kanidm/webauthn-rs/tree/master/fido-mds/"
    click TI "https://github.com/kanidm/webauthn-rs/tree/master/tutorial/server/"
    click USB "https://github.com/kanidm/webauthn-rs/tree/master/webauthn-authenticator-rs/src/usb/"
    click NFC "https://github.com/kanidm/webauthn-rs/tree/master/webauthn-authenticator-rs/src/nfc/"
    click BT "https://github.com/kanidm/webauthn-rs/tree/master/webauthn-authenticator-rs/src/bluetooth/"
    click DC "https://github.com/kanidm/webauthn-rs/tree/master/device-catalog/"
    click ACA "https://github.com/kanidm/webauthn-rs/tree/master/attestation-ca/"
    click CTS "https://github.com/kanidm/webauthn-rs/tree/master/cable-tunnel-server/"
    click CT "https://github.com/kanidm/webauthn-rs/tree/master/compat_tester/"
    click FHID "https://github.com/kanidm/webauthn-rs/tree/master/fido-hid-rs/"
    click AI "https://github.com/kanidm/webauthn-rs/tree/master/webauthn-authenticator-rs/"
```
