Overview
The Icons service provides:- Favicon Fetching: Retrieve website favicons and icons
- Multiple Strategies: Try multiple icon sources (favicon.ico, manifest, meta tags)
- Caching: In-memory cache for frequently requested icons
- Domain Mapping: Handle special cases and CDN redirects
- Fallback Icon: Default icon for failed requests
- Performance: Fast icon delivery with minimal overhead
Architecture
Configuration
Fromsrc/Icons/Startup.cs:23:
Service Configuration
Icon Endpoint
Fromsrc/Icons/Controllers/IconsController.cs:55:
Icon Retrieval
GET /{hostname}/icon.png
Example: GET /github.com/icon.png
Response: Image file (PNG, ICO, SVG, etc.)
Icon Fetching Strategies
The service tries multiple strategies to find icons:1
Favicon.ico
Try standard
/favicon.ico location2
Web Manifest
Parse
/manifest.json for icon URLs3
HTML Meta Tags
Parse HTML for icon meta tags (
<link rel="icon">)4
Apple Touch Icon
Try Apple-specific touch icons
5
Fallback
Return default Bitwarden globe icon
HTML Parsing
HTML Icon Extraction
Caching Strategy
Memory Cache
Icons are cached in memory with size limits:Cache Configuration
Cache Rules
Fromsrc/Icons/Controllers/IconsController.cs:91:
Cache Logic
- Duration: Configurable hours (default: 24 hours)
- Size Limit: Total cache size limit
- Entry Size: Large icons (>50KB) not cached
- Priority: Not found results cached with high priority
Domain Mapping
Special domain handling for popular services:Domain Mapping
Fallback Icon
Fromsrc/Icons/Controllers/IconsController.cs:14:
Default Icon
- Domain not found
- Icon fetch failed
- Invalid URL
Middleware Pipeline
Fromsrc/Icons/Startup.cs:60:
Request Pipeline
Response Headers
Configuration Endpoint
HTTP Client Configuration
The service uses custom HTTP client configuration:HTTP Client Setup
Security Features
URL Validation
Validate and sanitize all input URLs
CSP Headers
Content-Security-Policy prevents script execution
CORS Policy
Allow only configured origins
Size Limits
Limit cached icon size to prevent abuse
Performance Optimization
Caching Benefits
- Reduces external HTTP requests
- Faster icon loading for users
- Lower bandwidth usage
- Improved vault performance
Cache Eviction
Least Recently Used (LRU) eviction when cache is full:Deployment
Environment Variables
Docker
Kubernetes
Deployment
Monitoring
Metrics to Track
- Cache hit rate
- Icon fetch latency
- Failed fetches
- Cache size utilization
- Request rate
Health Check
Troubleshooting
Common Issues
Debug Logging
Self-Hosted Considerations
For air-gapped environments, consider pre-populating cache or disabling icon fetching.
Firewall Requirements
The Icons service needs outbound HTTPS access to:- Any website domain users have vault items for
- Port 443 (HTTPS)
- Port 80 (HTTP, redirects to HTTPS)
Related Services
- API Service - References icons for vault items
- Web Vault - Displays icons in UI