Security Best Practices
Keep your DotPassport integration secure.
API Key Security
Never Expose in Client Code
API keys should be treated as sensitive credentials:
// ❌ Bad - hardcoded API key
const client = new DotPassportClient({
apiKey: 'dp_live_abc123xyz'
});
// ✅ Good - environment variable
const client = new DotPassportClient({
apiKey: process.env.DOTPASSPORT_API_KEY
});Environment Variables
React (Vite)
# .env
VITE_DOTPASSPORT_API_KEY=your_api_keyNext.js
Node.js Backend
Rate Limiting Protection
Protect your API key from abuse:
Input Validation
Always validate user input before making API calls:
CORS Configuration
If you're proxying API requests through your backend:
Content Security Policy
Add appropriate CSP headers:
Secure Widget Embedding
Iframe Sandboxing
If embedding widgets in iframes:
Subresource Integrity
When using CDN:
Data Privacy
Minimal Data Collection
Only request what you need:
Cache Sensitive Data Carefully
Error Message Handling
Don't expose internal errors to users:
Backend Proxy Pattern
For maximum security, proxy requests through your backend:
Security Checklist
Reporting Security Issues
If you discover a security vulnerability in the SDK:
Do not disclose publicly
Email [email protected]
Include detailed reproduction steps
Allow reasonable time for fix before disclosure
Related
Last updated
