CardDAV Integration Technical Specification
☁️ OxiCloud server, efficient and secure way to save all your data
CardDAV Integration Technical Specification
#Overview
This document outlines the technical specification for implementing CardDAV support in OxiCloud, allowing users to synchronize their contacts across various devices and applications.
CardDAV (Card Distributed Authoring and Versioning) is an address book client/server protocol designed to allow users to access and share contact data on a server. It's an extension of WebDAV (RFC 4918) and is defined in RFC 6352.
#Architecture
The CardDAV implementation will follow the established hexagonal architecture pattern used throughout OxiCloud:
┌───────────────────┐ ┌────────────────────┐ ┌────────────────────┐
│ │ │ │ │ │
│ Interfaces │ │ Application │ │ Infrastructure │
│ - CardDAV API │────▶│ - Contact Service │────▶│ - Contact Repo │
│ - Contact API │ │ - CardDAV Adapter │ │ - PG Repository │
│ │ │ │ │ │
└───────────────────┘ └────────────────────┘ └────────────────────┘
│
▼
┌────────────────────┐
│ │
│ Domain │
│ - Contact Entity │
│ - Address Book │
│ │
└────────────────────┘
#Components
-
Domain Layer
Contactentity - Represents a contact with properties like name, email, phone, etc.AddressBookentity - Represents a collection of contacts- Repository interfaces for contact management
-
Application Layer
ContactService- Business logic for managing contactsCardDAVAdapter- Converts between CardDAV protocol requests/responses and domain objects
-
Infrastructure Layer
ContactPgRepository- PostgreSQL implementation of contact repositoriesAddressBookPgRepository- PostgreSQL implementation of address book repositories
-
Interface Layer
- REST API endpoints for contact management
- CardDAV protocol endpoints (WebDAV extension)
#Database Schema
The following database schema will be used to store contact information:
#API Endpoints
#REST API
The following REST endpoints will be implemented for managing contacts:
#CardDAV Protocol Endpoints
The following CardDAV protocol endpoints will be implemented:
#Data Model
#Contact Entity
#AddressBook Entity
#Repositories
#Contact Repository Interface
#AddressBook Repository Interface
#CardDAV Protocol Implementation
The CardDAV implementation will support the following features:
- Address Book Discovery - Allow clients to discover available address books
- Address Book Collection - Manage contacts within address books
- vCard Support - Store and retrieve contacts in vCard format (3.0 and 4.0)
- Query Support - Filter contacts by properties
- Multiget Support - Retrieve multiple contacts in a single request
- Sync-Collection - Efficient synchronization of changes
#CardDAV Adapter
The CardDAV adapter will handle:
- Parsing CardDAV XML requests
- Converting between vCard and Contact entities
- Generating CardDAV XML responses
- Supporting PROPFIND, REPORT, and other WebDAV methods
- Implementing the proper WebDAV properties for CardDAV
#Integration Points
The CardDAV implementation will integrate with:
- Authentication System - Reuse existing auth mechanisms
- WebDAV Infrastructure - Extend the existing WebDAV implementation
- Database Layer - Store contacts in PostgreSQL
- User Management - Connect contacts with user accounts
#Client Compatibility
The implementation should be compatible with the following clients:
- Apple Contacts
- Google Contacts
- Thunderbird
- Outlook
- Android DAVx⁵
- iOS native contacts app
- Evolution
#Implementation Phases
The implementation will be divided into the following phases:
#Phase 1: Core Infrastructure
- Database schema creation
- Entity definitions
- Repository interfaces
- Basic DTO and port definitions
#Phase 2: Core Business Logic
- Address book management service
- Contact management service
- vCard parsing and generation
#Phase 3: REST API
- Address book endpoints
- Contact management endpoints
- Contact group endpoints
#Phase 4: CardDAV Protocol
- CardDAV adapter implementation
- WebDAV method handlers
- XML parsing and generation
- Protocol compliance testing
#Phase 5: Testing and Refinement
- Integration testing with client applications
- Performance optimization
- Edge case handling
#Security Considerations
The CardDAV implementation must address the following security concerns:
- Authentication - Ensure proper authentication for all operations
- Authorization - Verify permissions for each address book operation
- Data Validation - Validate vCard input to prevent injection attacks
- Resource Limits - Implement limits to prevent abuse
- Error Handling - Provide appropriate error responses without revealing sensitive information
#Performance Considerations
To ensure good performance:
- Indexing - Proper database indexes for contact queries
- Caching - Cache frequently accessed address books and contacts
- Pagination - Support pagination for large address books
- Incremental Sync - Efficient synchronization with client devices
- ETags - Use ETags to prevent unnecessary data transfers
#Testing Strategy
The CardDAV implementation will be tested using:
- Unit Tests - Test individual components in isolation
- Integration Tests - Test the interaction between components
- Protocol Compliance Tests - Verify adherence to the CardDAV specification
- Client Compatibility Tests - Test with various CardDAV clients
- Performance Tests - Measure performance with large address books
Quick Actions
Details
- Type
- Technical Spec
- Author
- DioCrafts
- Slug
- diocrafts/doc-carddav-integration-technical-specification
