Skip to content

Latest commit

 

History

History
395 lines (304 loc) · 9.46 KB

File metadata and controls

395 lines (304 loc) · 9.46 KB

D2D API-Based Deployment Summary

✅ What Was Implemented

Instead of exposing the entire D2D web application via public IP (Option 3), we've implemented a secure API-based approach where:

  1. D2D API endpoints are protected with API key authentication
  2. VRG Hub builds its own UI and calls D2D's API
  3. D2D can stay on private network (10.200.1.8) - more secure
  4. No iframe/mixed content issues - clean HTTPS throughout

🏗️ Architecture

Previous Approach (iframe - not recommended)

User Browser (HTTPS)
    ↓
VRG Hub (HTTPS) → iframe embedding → D2D UI (HTTP) ❌ Mixed content warning
    ↓
D2D Backend (Public IP required)

Problems:

  • ❌ Mixed content warnings (HTTPS → HTTP)
  • ❌ Entire D2D UI exposed to internet
  • ❌ No authentication
  • ❌ Security risks with PHI

New Approach (API-based - recommended ✅)

User Browser (HTTPS)
    ↓
VRG Hub Frontend (React UI - HTTPS)
    ↓
VRG Hub Backend Proxy (adds API key)
    ↓ HTTP + X-API-Key header
D2D API (Private: 10.200.1.8:8000)
    ↓
PACS/Worklist

Benefits:

  • ✅ No mixed content warnings
  • ✅ D2D stays on private network
  • ✅ API authentication (X-API-Key)
  • ✅ VRG Hub controls UX
  • ✅ Better security posture

🔐 Security Implementation

API Key Authentication

All D2D API endpoints now require:

X-API-Key: your-api-key-here

Configured via environment variable:

D2D_API_KEYS=key1,key2,key3

Default for testing:

vrg-api-key-2026-secure-change-me

Production: Generate secure keys and set in environment

What's Protected

Protected (require API key):

  • ✅ POST /api/upload - File upload
  • ✅ POST /api/convert - DICOM conversion
  • ✅ POST /api/send - Send to PACS
  • ✅ POST /api/worklist/query - Worklist query
  • ✅ POST /api/worklist/test - Test worklist connection
  • ✅ GET /api/destinations - Get destinations
  • ✅ POST /api/destinations - Add destination
  • ✅ DELETE /api/destinations/{name} - Delete destination
  • ✅ POST /api/destinations/verify - Verify PACS connection
  • ✅ GET /api/archives - List archives
  • ✅ GET /api/archives/{filename} - Download archive
  • ✅ GET /api/worklist/config - Get worklist config

Public (no authentication):

  • / - HTML UI (for direct access if needed)
  • /worklist - Worklist HTML UI
  • /diagnostics - Diagnostics page
  • /static/* - Static files (CSS, JS)

📚 Documentation Created

1. API Documentation

File: /home/claudeagent/d2d/API-DOCUMENTATION.md

Contains:

  • Complete API reference for all endpoints
  • Request/response examples
  • Authentication details
  • Error handling
  • Usage workflows

2. VRG Hub Integration Guide

File: /home/claudeagent/vrg-hub/D2D-API-INTEGRATION-GUIDE.md

Contains:

  • Step-by-step integration guide
  • Backend proxy configuration (Vite, Next.js, Express)
  • Frontend React component examples
  • Complete workflow implementation
  • Security best practices
  • Deployment checklist

🚀 How to Use

For D2D Administrators

1. Set API Key (Production):

# On d2d-vm
ssh azureuser@10.200.1.8
cd /opt/d2d

# Generate secure API key
export D2D_API_KEYS="$(openssl rand -hex 32)"

# Add to docker-compose.yml or .env
echo "D2D_API_KEYS=${D2D_API_KEYS}" >> .env

# Restart D2D
sudo docker-compose down
sudo docker-compose up -d

# Share API key securely with VRG Hub team
echo $D2D_API_KEYS

2. Keep D2D on Private Network:

# Remove public IP if previously added
az network nic ip-config update \
  --resource-group VRG-PAX8 \
  --nic-name d2d-vmVMNic \
  --name ipconfigd2d-vm \
  --remove publicIPAddress

3. Monitor API Usage:

# Check logs for API calls
ssh azureuser@10.200.1.8
cd /opt/d2d
sudo docker-compose logs -f | grep "X-API-Key"

For VRG Hub Developers

1. Add D2D API proxy to VRG Hub backend

See: /home/claudeagent/vrg-hub/D2D-API-INTEGRATION-GUIDE.md

Quick Start (Vite):

// vite.config.ts
export default defineConfig({
  server: {
    proxy: {
      '/api/d2d': {
        target: 'http://10.200.1.8:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/d2d/, '/api'),
        configure: (proxy) => {
          proxy.on('proxyReq', (proxyReq) => {
            proxyReq.setHeader('X-API-Key', process.env.D2D_API_KEY || 'vrg-api-key-2026-secure-change-me');
          });
        },
      },
    },
  },
});

2. Build D2D UI in VRG Hub

See example component in integration guide.

3. Test the integration

// Test upload
const formData = new FormData();
formData.append('file', file);

const response = await fetch('/api/d2d/upload', {
  method: 'POST',
  body: formData
});

console.log(await response.json());
// Expected: { file_id: "...", filename: "...", size: ... }

📊 Current Status

D2D Backend

  • ✅ API key authentication implemented
  • ✅ All endpoints protected
  • ✅ Documentation complete
  • ✅ Committed to GitHub
  • ⏳ Pending: Deploy to d2d-vm (auto-deployment will handle)

D2D Network

  • Current: Public IP (4.198.108.152:8000) - can be removed
  • Recommended: Keep on private IP (10.200.1.8:8000)
  • API still works with authentication

VRG Hub

  • ✅ Integration guide complete
  • ⏳ Pending: Implement backend proxy
  • ⏳ Pending: Build D2D UI component
  • ⏳ Pending: Deploy and test

🔄 Migration Path

From iframe Approach

If you previously implemented the iframe approach:

1. Remove public IP exposure (optional but recommended):

# If you want to keep D2D fully private
az network nic ip-config update \
  --resource-group VRG-PAX8 \
  --nic-name d2d-vmVMNic \
  --name ipconfigd2d-vm \
  --remove publicIPAddress

2. Update VRG Hub:

  • Remove iframe-based D2dConverter component
  • Implement API proxy in backend
  • Build new UI component using D2D API
  • Test workflow: upload → convert → send

3. Deploy:

  • Set D2D_API_KEY environment variable
  • Deploy VRG Hub with new implementation
  • Test from production URL

🔧 Deployment

D2D VM

Auto-deployment is active!

Changes will auto-deploy within 15 minutes via the GitHub auto-deploy script.

Manual deployment:

ssh azureuser@10.200.1.8
cd /opt/d2d
git pull origin master
sudo docker-compose down
sudo docker-compose build
sudo docker-compose up -d

Verify deployment:

# Test API without key (should fail with 401)
curl http://10.200.1.8:8000/api/destinations

# Test with API key (should succeed)
curl -H "X-API-Key: vrg-api-key-2026-secure-change-me" \
  http://10.200.1.8:8000/api/destinations

VRG Hub

Follow the integration guide to implement the API proxy and UI components.


🎯 Next Steps

Immediate

  1. Test API authentication on D2D:

    • Wait for auto-deployment (~15 min)
    • Test with curl
    • Verify all endpoints require API key
  2. Generate production API key:

    • Use strong random key
    • Store securely in D2D environment
    • Share with VRG Hub team securely

Short Term (This Week)

  1. VRG Hub implementation:

    • Add backend proxy
    • Build D2D UI component
    • Test upload/convert/send workflow
    • Test worklist query integration
  2. Security review:

    • Ensure API key in environment only
    • Verify D2D on private network
    • Test authentication enforcement
    • Review access logs

Medium Term (This Month)

  1. Enhanced security:

    • Rate limiting on API
    • Enhanced logging and monitoring
    • API key rotation procedure
    • Alert on failed auth attempts
  2. Documentation:

    • VRG Hub user guide
    • Admin procedures
    • Troubleshooting guide
    • API changelog

📖 Reference Documentation

Document Location Purpose
API Documentation /home/claudeagent/d2d/API-DOCUMENTATION.md Complete API reference
VRG Hub Integration Guide /home/claudeagent/vrg-hub/D2D-API-INTEGRATION-GUIDE.md Integration instructions
Public IP Deployment /home/claudeagent/d2d/PUBLIC-IP-DEPLOYMENT.md Public IP approach (not recommended)
Worklist Feature /home/claudeagent/d2d/WORKLIST-FEATURE.md Worklist functionality
VM Deployment /home/claudeagent/d2d/VM-DEPLOYMENT-INFO.md D2D VM details

🆚 Comparison: iframe vs API

Aspect iframe Approach API Approach
Security ❌ UI exposed ✅ API only, with auth
Network ❌ Needs public IP ✅ Private network OK
HTTPS ❌ Mixed content warning ✅ HTTPS throughout
UX Control ❌ Limited (iframe constraints) ✅ Full control
Authentication ❌ None or HTTP Basic ✅ API key
Performance ⚠️ iframe overhead ✅ Direct API calls
Maintenance ⚠️ Two UIs to maintain ✅ Single UI in VRG Hub
Mobile ⚠️ iframe sizing issues ✅ Responsive design

Winner: API Approach ✅


✅ Summary

What we did:

  1. Added API key authentication to D2D
  2. Created comprehensive API documentation
  3. Created VRG Hub integration guide
  4. Committed everything to GitHub

What you get:

  • Secure D2D API with authentication
  • D2D can stay on private network
  • VRG Hub can build custom UI
  • No mixed content warnings
  • Better security posture

What's next:

  • Auto-deployment will update D2D (within 15 min)
  • VRG Hub team implements API integration
  • Test and deploy

Document Created: 2026-01-23 Last Updated: 2026-01-23 Status: ✅ Implementation Complete - Ready for VRG Hub Integration