Overview
The GDPR compliance endpoints (/api/v1/users/me/*) require persistent storage to meet data subject rights requirements under GDPR Articles 15, 16, 17, 20, and 21.
CRITICAL: In-memory storage is NOT production-ready and will cause data loss on server restart, violating GDPR compliance requirements.
PostgreSQL storage backend is fully implemented as of ADR-0041 (2025-11-02). See ADR-0041: PostgreSQL GDPR Storage for architecture details.
GDPR Data Subject Rights Flow
Environment Variables
Required Configuration
Set these environment variables in your production deployment:Development/Testing
For local development and testing only:Storage Backend Options
Option 1: PostgreSQL (Recommended) ✅
PostgreSQL provides ACID compliance and is ideal for GDPR data subject rights. Fully implemented as of ADR-0041.Production Ready: PostgreSQL storage backend is fully implemented with factory pattern, migrations, and comprehensive testing.
- ACID Compliance: Atomic GDPR Article 17 deletions across all data
- Cost-Effective: 14x cheaper than Redis for 7-year retention (720/month)
- Audit Trail: Time-series queries for compliance reports
- Already in Stack: Keycloak and OpenFGA use PostgreSQL
- 5-10ms Latency: Acceptable for user-initiated GDPR operations
deployments/base/postgres-gdpr-schema-configmap.yaml and automatically applied during PostgreSQL initialization.
Factory Pattern Usage:
Option 2: Redis
Redis provides fast, persistent key-value storage suitable for consent management. Configuration:- Create
RedisConsentStoreclass - Use Redis hashes for user profiles:
user:profile:{user_id} - Use Redis hashes for consents:
user:consents:{user_id} - Configure TTL if retention policies apply
Production Guard
The application includes a runtime guard that prevents startup if:Migration Checklist
Before deploying GDPR endpoints to production:- Set
ENVIRONMENT=production - Set
GDPR_STORAGE_BACKEND=postgres - Configure
GDPR_POSTGRES_URLconnection string - Deploy PostgreSQL GDPR schema (see Kubernetes deployment section)
- Apply
postgres-gdpr-schema-configmap.yamlto create database tables - Run database migrations from
migrations/directory (if any schema updates) - Test data subject rights workflows (see Testing section)
- Verify data is persisted across pod/container restarts
- Configure automated backups (daily PostgreSQL dumps recommended)
- Configure retention policies (see Data Retention section)
- Document data retention periods in privacy policy
- Update privacy policy with GDPR data subject rights
- Test GDPR API endpoints (see GDPR API Reference)
- Verify audit logging for all GDPR operations
GDPR_STORAGE_BACKEND environment variable.
Database Migrations
Themigrations/ directory contains schema migrations for PostgreSQL GDPR storage:
postgres-gdpr-schema ConfigMap during PostgreSQL StatefulSet initialization. See deployments/base/postgres-statefulset.yaml for implementation details.
Future schema changes will be added as numbered migrations. Always apply migrations in sequential order.
GDPR Compliance Requirements
Data Retention
Configure retention policies based on your legal requirements:Audit Trail
All GDPR operations are logged with:- User ID
- Operation type (access, rectification, erasure, etc.)
- Timestamp
- GDPR article (15, 16, 17, 20, 21)
Data Deletion (Article 17)
When users exercise right to erasure:- User profile and preferences are deleted
- Consent records are deleted
- Audit logs are anonymized (user_id replaced with hash)
- Sessions are revoked
- Conversations are deleted
- Anonymized audit logs (for GDPR compliance proof)
- Aggregated analytics (no PII)
- Financial records (tax law requirements)
Testing
Unit Tests
Integration Tests
Test with real database:Production Guard Test
Verify production guard:Deployment Examples
Docker Compose
Kubernetes
Troubleshooting
Error: “GDPR endpoints use in-memory storage”
Cause: GDPR_STORAGE_BACKEND not set or set to “memory” Solution:Error: “RuntimeError: CRITICAL: GDPR endpoints cannot use in-memory storage”
Cause: Running in production with memory backend Solution: Change backend or environment:Data Loss on Restart
Cause: Using in-memory storage in non-development environment Solution: Migrate to PostgreSQL or Redis immediatelyReferences
- GDPR Article 15: Right to Access
- GDPR Article 16: Right to Rectification
- GDPR Article 17: Right to Erasure
- GDPR Article 20: Right to Data Portability
- GDPR Article 21: Right to Object
Support
For implementation assistance:- Check existing issues: https://github.com/vishnu2kmohan/mcp-server-langgraph/issues
- Create new issue with
gdprandcompliancelabels - Include environment details and error messages