De.Auth Architecture
The de.auth service is designed as a secure authentication provider for the De. platform, enabling phone-based verification, account management, and secure user sessions.
System Architecture
Authentication Flow
The authentication flow in de.auth is based on phone number verification:
Component Architecture
Database Schema
Users Collection
json
{
"profile": {
"firstName": "John",
"lastName": "Doe",
"phone": "+1234567890",
"email": "[email protected]",
"photo": "https://storage.dedot.io/profile/user123.jpg",
"country": {
"code": "US",
"name": "United States"
}
},
"account": {
"uid": "user_12345",
"type": "PERSONAL",
"isRestricted": false,
"agreeTerms": true,
"settings": {
"theme": {
"mode": "auto",
"fontSize": "normal"
},
"notification": {
"push": "token123",
"sms": false,
"email": true
},
"privacy": {
"publicView": false
}
}
},
"connection": {
"lastOnline": 1642561234567,
"devices": {
"device_123": {
"isConnected": true,
"status": "activated",
"ctoken": "connection_token_123",
"datetime": 1642561234567,
"platform": "iOS",
"model": "iPhone 13",
"country": "United States",
"city": "New York"
}
},
"history": [
{
"deviceId": "device_123",
"status": "SIGNIN",
"userAgent": "Mobile App 1.0",
"service": "MyService",
"datetime": 1642561234567,
"country": "United States",
"city": "New York"
}
]
},
"datetime": 1642561234567
}Auth Collection
json
{
"phone": "+1234567890",
"code": 123456,
"device": {
"platform": "iOS",
"model": "iPhone 13",
"userAgent": "Mobile App 1.0",
"service": "MyService"
},
"sms": {
"delay": 60,
"sentAt": 1642561234567
},
"expiry": 1642564834567
}Security Features
Phone Number Verification
- One-time verification codes
- Expiry mechanism for verification codes
- Rate limiting for SMS sending
Session Management
- Device tracking and fingerprinting
- Connection token generation and validation
- Last activity tracking
Request Authorization
- Header-based authentication
- Role-based access control
- Service identification
Security Headers
- CORS protection
- Content security policies
- Rate limiting headers
Error Handling
- Sanitized error responses
- Detailed logging (development only)
- Graceful fallbacks

