|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the FIDO2 .NET Library (WebAuthn) - a working implementation library for FIDO2 and WebAuthn using .NET. It provides a developer-friendly and well-tested .NET FIDO2 Server/WebAuthn relying party library for validation of registration (attestation) and authentication (assertion) of FIDO2/WebAuthn credentials. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +The solution is organized into several key projects: |
| 12 | + |
| 13 | +### Core Library Projects |
| 14 | + |
| 15 | +- **Src/Fido2.Models** - Core data models and DTOs for FIDO2/WebAuthn, shared across all projects |
| 16 | +- **Src/Fido2** - Main FIDO2 library with attestation/assertion verification logic, cryptographic operations, and metadata service integration |
| 17 | +- **Src/Fido2.AspNet** - ASP.NET Core integration helpers and extensions |
| 18 | +- **Src/Fido2.Ctap2** - CTAP2 protocol implementation for FIDO2 authenticators |
| 19 | +- **Src/Fido2.BlazorWebAssembly** - Blazor WebAssembly-specific components and helpers |
| 20 | +- **Src/Fido2.Development** - Development and testing utilities |
| 21 | + |
| 22 | +### Demo/Example Projects |
| 23 | + |
| 24 | +- **Demo** - ASP.NET Core demo application showing FIDO2 registration and authentication flows |
| 25 | +- **BlazorWasmDemo** - Blazor WebAssembly demo application (Client/Server projects) |
| 26 | + |
| 27 | +### Test Projects |
| 28 | + |
| 29 | +- **Tests/Fido2.Tests** - Main unit test suite using xUnit |
| 30 | +- **Tests/Fido2.Ctap2.Tests** - Tests for CTAP2 functionality |
| 31 | + |
| 32 | +## Development Commands |
| 33 | + |
| 34 | +### Building |
| 35 | + |
| 36 | +```bash |
| 37 | +# Build entire solution |
| 38 | +dotnet build fido2-net-lib.sln --configuration Release |
| 39 | + |
| 40 | +# Build specific project |
| 41 | +dotnet build Demo/Demo.csproj --configuration Release |
| 42 | +``` |
| 43 | + |
| 44 | +### Testing |
| 45 | + |
| 46 | +```bash |
| 47 | +# Run all tests |
| 48 | +dotnet test Tests/Fido2.Tests/Fido2.Tests.csproj |
| 49 | + |
| 50 | +# Run tests with coverage |
| 51 | +dotnet test Tests/Fido2.Tests/Fido2.Tests.csproj --collect:"XPlat Code Coverage" |
| 52 | +``` |
| 53 | + |
| 54 | +### Code Formatting |
| 55 | + |
| 56 | +```bash |
| 57 | +# Check formatting |
| 58 | +dotnet format --verify-no-changes --no-restore |
| 59 | + |
| 60 | +# Apply formatting |
| 61 | +dotnet format |
| 62 | +``` |
| 63 | + |
| 64 | +### Running Demo Applications |
| 65 | + |
| 66 | +```bash |
| 67 | +# Run ASP.NET Core demo (requires HTTPS, expected at https://localhost:44329) |
| 68 | +dotnet run --project Demo/Demo.csproj |
| 69 | + |
| 70 | +# Run Blazor WebAssembly demo |
| 71 | +dotnet run --project BlazorWasmDemo/Server/BlazorWasmDemo.Server.csproj |
| 72 | +``` |
| 73 | + |
| 74 | +## Configuration |
| 75 | + |
| 76 | +### Key Configuration Files |
| 77 | + |
| 78 | +- **Directory.Build.props** - Root build configuration with package metadata and global settings |
| 79 | +- **Src/Directory.Build.props** - Source-specific build settings |
| 80 | +- **azure-pipelines.yml** - CI/CD pipeline configuration |
| 81 | + |
| 82 | +### Important Settings |
| 83 | + |
| 84 | +- Target Framework: .NET 8.0 (configured via `SupportedTargetFrameworks`) |
| 85 | +- Language Version: C# 12 |
| 86 | +- Nullable reference types enabled |
| 87 | +- ImplicitUsings enabled globally |
| 88 | +- TreatWarningsAsErrors enabled |
| 89 | + |
| 90 | +## Code Style Guidelines |
| 91 | + |
| 92 | +- Use 4 spaces for indentation (no tabs) |
| 93 | +- Use `_camelCase` for private fields |
| 94 | +- Always specify member visibility explicitly |
| 95 | +- Use `var` keyword when type is obvious |
| 96 | +- Use primitive type keywords (`int` vs `Int32`) |
| 97 | +- Document public APIs with XmlDoc comments |
| 98 | +- Avoid `this.` unless necessary |
| 99 | +- Use expression-bodied members when appropriate for readability |
| 100 | + |
| 101 | +## Key Dependencies |
| 102 | + |
| 103 | +- **NSec.Cryptography** - Cryptographic operations |
| 104 | +- **System.Formats.Cbor** - CBOR encoding/decoding |
| 105 | +- **Microsoft.IdentityModel.JsonWebTokens** - JWT token handling |
| 106 | +- **Microsoft.Extensions.Http** - HTTP client factory |
| 107 | + |
| 108 | +## Testing Framework |
| 109 | + |
| 110 | +- **xUnit** - Primary test framework |
| 111 | +- **Moq** - Mocking framework |
| 112 | +- **coverlet.collector** - Code coverage collection |
| 113 | + |
| 114 | +## Important Notes |
| 115 | + |
| 116 | +- The project passes 100% of FIDO Alliance conformance tests |
| 117 | +- Supports all current attestation formats: packed, tpm, android-key, android-safetynet, fido-u2f, apple, apple-appattest, and none |
| 118 | +- Includes FIDO Metadata Service V3 validation support |
| 119 | +- Cross-platform compatible (Windows, macOS, Linux) |
| 120 | +- Root namespace is `Fido2NetLib` for all projects |
0 commit comments