|
| 1 | +# Data Retention Policy |
| 2 | + |
| 3 | +This document outlines data retention practices for the Liturgical Calendar API, particularly regarding |
| 4 | +audit logs that may contain personal data subject to privacy regulations (GDPR, CCPA, etc.). |
| 5 | + |
| 6 | +## Audit Logging |
| 7 | + |
| 8 | +### Purpose |
| 9 | + |
| 10 | +The API logs audit events for write operations (PUT, PATCH, DELETE) to track changes to calendar data. |
| 11 | +This supports: |
| 12 | + |
| 13 | +- Security monitoring and incident response |
| 14 | +- Change tracking and accountability |
| 15 | +- Debugging and troubleshooting |
| 16 | + |
| 17 | +### Data Collected |
| 18 | + |
| 19 | +Audit log entries include: |
| 20 | + |
| 21 | +| Field | Description | Personal Data | |
| 22 | +|-------------|-----------------------------------------------|---------------| |
| 23 | +| `operation` | HTTP method (PUT, PATCH, DELETE) | No | |
| 24 | +| `category` | Calendar type (diocese, nation, widerregion) | No | |
| 25 | +| `key` | Calendar identifier | No | |
| 26 | +| `client_ip` | IP address of the request origin | **Yes** | |
| 27 | +| `files` | Affected file paths | No | |
| 28 | +| `datetime` | Timestamp of the operation | No | |
| 29 | + |
| 30 | +### Retention Period |
| 31 | + |
| 32 | +Audit logs are configured with a **90-day retention period** via rotating file handlers. |
| 33 | + |
| 34 | +```php |
| 35 | +// In RegionalDataHandler constructor |
| 36 | +$this->auditLogger = LoggerFactory::create('audit', null, 90, false, true, false); |
| 37 | +// ^^ |
| 38 | +// maxFiles = 90 days of rotation |
| 39 | +``` |
| 40 | + |
| 41 | +After 90 days, log files are automatically deleted by the Monolog rotating file handler. |
| 42 | + |
| 43 | +### Storage Location |
| 44 | + |
| 45 | +Audit logs are stored in: |
| 46 | + |
| 47 | +```text |
| 48 | +logs/audit.json-YYYY-MM-DD.log |
| 49 | +``` |
| 50 | + |
| 51 | +Each day's logs are in a separate file in NDJSON (Newline Delimited JSON) format. |
| 52 | + |
| 53 | +## Privacy Considerations |
| 54 | + |
| 55 | +### IP Addresses as Personal Data |
| 56 | + |
| 57 | +Under GDPR and similar regulations, IP addresses are considered personal data because they can |
| 58 | +potentially identify individuals. The API collects client IP addresses for legitimate security |
| 59 | +and auditing purposes. |
| 60 | + |
| 61 | +### Legal Basis (GDPR) |
| 62 | + |
| 63 | +The collection of IP addresses for audit logging may be justified under: |
| 64 | + |
| 65 | +- **Article 6(1)(f)** - Legitimate interests: Security monitoring and protecting the integrity |
| 66 | + of calendar data |
| 67 | +- **Article 6(1)(c)** - Legal obligation: If required for compliance with security standards |
| 68 | + |
| 69 | +### Data Subject Rights |
| 70 | + |
| 71 | +If operating in jurisdictions covered by privacy regulations, consider implementing: |
| 72 | + |
| 73 | +1. **Right to Access**: Ability to search logs for a specific IP address |
| 74 | +2. **Right to Erasure**: Process for anonymizing or deleting logs containing specific IPs |
| 75 | +3. **Data Processing Records**: Document audit logging in your Records of Processing Activities (ROPA) |
| 76 | + |
| 77 | +## Recommendations |
| 78 | + |
| 79 | +### For Production Deployments |
| 80 | + |
| 81 | +1. **Document the retention period** in your privacy policy |
| 82 | +2. **Restrict log access** to authorized personnel only |
| 83 | +3. **Consider log encryption** for sensitive environments |
| 84 | +4. **Review retention period** based on your organization's requirements and applicable regulations |
| 85 | + |
| 86 | +### Configuration Options |
| 87 | + |
| 88 | +The retention period can be adjusted in `RegionalDataHandler.php`: |
| 89 | + |
| 90 | +```php |
| 91 | +// Change 90 to desired number of days |
| 92 | +$this->auditLogger = LoggerFactory::create('audit', null, 30, false, true, false); |
| 93 | +``` |
| 94 | + |
| 95 | +### Log Access Control |
| 96 | + |
| 97 | +Ensure the `logs/` directory has appropriate permissions: |
| 98 | + |
| 99 | +```bash |
| 100 | +chmod 750 logs/ |
| 101 | +chown www-data:www-data logs/ |
| 102 | +``` |
| 103 | + |
| 104 | +## Related Files |
| 105 | + |
| 106 | +- `src/Handlers/RegionalDataHandler.php` - Audit logging implementation |
| 107 | +- `src/Http/Logs/LoggerFactory.php` - Logger factory with rotation configuration |
| 108 | +- `src/Handlers/Auth/ClientIpTrait.php` - Client IP extraction logic |
| 109 | + |
| 110 | +## Changelog |
| 111 | + |
| 112 | +| Date | Change | |
| 113 | +|---------|--------------------------------------------------------------------| |
| 114 | +| 2025-11 | Initial documentation of audit logging and 90-day retention policy | |
0 commit comments