The Legal AI Toolkit uses a dual-strategy approach for token storage based on the platform:
- Strategy: OS-native secure storage (keyring/keychain)
- Implementation: Uses
keyringcrate for platform-specific storage- Windows: Windows Credential Manager
- macOS: macOS Keychain
- Linux: Secret Service API
- Security Level: ✅ High - Tokens encrypted at rest by OS
- Fallback: ❌ None - No plaintext fallback for maximum security
- Strategy: Browser localStorage
- Implementation: Standard browser storage API
- Security Level:
⚠️ Medium - Tokens stored in browser storage - Justification: Standard practice for web applications, acceptable for web context
- Mitigation: Short token expiry (30 minutes), automatic refresh
- Token Lifetime: 30 minutes
- Refresh Interval: 20 minutes (10-minute safety buffer)
- Automatic Refresh: Background refresh for active sessions
- Failure Handling: Graceful logout on refresh failure
- API_BASE_URL: Required environment variable
- Validation: Strict requirement when
ENVIRONMENT=production - Protocol: HTTPS enforced for production
- API_BASE_URL: Optional, defaults to
http://localhost:8000 - Stripe Keys: Test keys (
sk_test_*) automatically detected - Protocol: HTTP acceptable for local development
Run the security validation script before any deployment:
python3 scripts/validate-security-fixes.py- Pre-commit hooks: Security scan on code changes
- CI/CD integration: Automated security validation
- Environment validation: Check required variables
- No hardcoded credentials in source code
- Environment variables properly configured
- Keyring integration working on target platform
- Token refresh logic functioning
- Error handling doesn't leak sensitive information
- HTTPS enforced in production
- Security validation passing
- No hardcoded secrets: All sensitive data via environment variables
- Proper error handling: Structured errors without information leakage
- Logging: Security events logged for monitoring
- Input validation: All user inputs validated and sanitized
- Regular updates: Keep dependencies current
- Security scanning: Automated vulnerability scanning
- Minimal dependencies: Only include necessary packages
- Failed authentication attempts: Logged and monitored
- Token manipulation: Detected and logged
- Unusual API access: Flagged for review
- Immediate: Isolate affected systems
- Assessment: Determine scope and impact
- Mitigation: Apply appropriate fixes
- Recovery: Restore secure operations
- Review: Post-incident analysis and improvements
- Security Lead: [To be configured]
- Development Team: [To be configured]
- Infrastructure: [To be configured]
# Production API endpoint
export API_BASE_URL=https://api.yourdomain.com
# Stripe production keys
export STRIPE_SECRET_KEY=sk_live_YOUR_PRODUCTION_KEY
export STRIPE_PUBLISHABLE_KEY=pk_live_YOUR_PRODUCTION_KEY
# Environment flag
export ENVIRONMENT=production- Authentication logs: Monitor for suspicious activity
- API access patterns: Detect anomalous usage
- Error rates: Track authentication failures
- Token usage: Monitor refresh patterns
- Data encryption: All sensitive data encrypted
- Access control: Minimal required permissions
- Audit trails: Complete logging of security events
- Recovery procedures: Documented restoration process
- OWASP: Following OWASP security guidelines
- Industry Standards: Implementing security best practices
- Regular Reviews: Periodic security assessments
- Data minimization: Only collect necessary data
- Encryption: Sensitive data encrypted at rest and in transit
- Access controls: Strict access management
- Retention policies: Appropriate data retention periods
- Critical: Immediate deployment
- High: Within 24 hours
- Medium: Within 1 week
- Low: Next regular deployment
- Security review: All changes reviewed for security impact
- Testing: Security testing before deployment
- Documentation: Security implications documented
- Rollback: Rapid rollback capability maintained
Last Updated: 2024-01-15
Version: 1.0
Next Review: 2024-04-15