You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(gdpr): add GDPR documentation and disable by default
- Change user.gdpr.enabled default to false for backward compatibility
- Add GDPR features to README.md Features list
- Add comprehensive GDPR Compliance section to README.md with:
- Configuration instructions
- Data export (Right of Access) documentation
- Account deletion (Right to be Forgotten) documentation
- Consent management API documentation
- GdprDataContributor extensibility guide
- GDPR events reference
- Add GDPR configuration section to CONFIG.md
- Add user.audit.maxQueryResults to CONFIG.md
Copy file name to clipboardExpand all lines: CONFIG.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,26 @@ Welcome to the User Framework SpringBoot Configuration Guide! This document outl
38
38
39
39
-**Log File Path (`user.audit.logFilePath`)**: The path to the audit log file.
40
40
-**Flush on Write (`user.audit.flushOnWrite`)**: Set to `true` for immediate log flushing. Defaults to `false` for performance.
41
+
-**Max Query Results (`user.audit.maxQueryResults`)**: Maximum number of audit events returned from queries. Prevents memory issues with large logs. Defaults to `10000`.
42
+
43
+
## GDPR Compliance
44
+
45
+
GDPR features are disabled by default and must be explicitly enabled.
46
+
47
+
-**Enable GDPR (`user.gdpr.enabled`)**: Master toggle for all GDPR features. When `false`, all GDPR endpoints return 404. Defaults to `false`.
48
+
-**Export Before Deletion (`user.gdpr.exportBeforeDeletion`)**: When `true`, user data is automatically exported and included in the deletion response. Defaults to `true`.
49
+
-**Consent Tracking (`user.gdpr.consentTracking`)**: Enable consent grant/withdrawal tracking via the audit system. Defaults to `true`.
50
+
51
+
**Example configuration:**
52
+
```yaml
53
+
user:
54
+
gdpr:
55
+
enabled: true
56
+
exportBeforeDeletion: true
57
+
consentTracking: true
58
+
```
59
+
60
+
**Note**: When GDPR is enabled, ensure you have a `UserPreDeleteEvent` listener configured to clean up application-specific user data before deletion. See the README for details.
@@ -92,6 +99,13 @@ Check out the [Spring User Framework Demo Application](https://github.com/devond
92
99
- Comprehensive documentation
93
100
- Demo application for reference
94
101
102
+
-**GDPR Compliance** (opt-in)
103
+
- Data export (Right of Access - Article 15)
104
+
- Account deletion (Right to be Forgotten - Article 17)
105
+
- Consent tracking and management (Article 7)
106
+
- Extensible data contributor system for custom data
107
+
- Audit trail for all GDPR operations
108
+
95
109
## Installation
96
110
97
111
Choose the version that matches your Spring Boot version:
@@ -747,6 +761,182 @@ By implementing such a listener, your application ensures data integrity when th
747
761
The framework supports SSO OAuth2 with Google, Facebook and Keycloak. To enable this you need to configure the client id and secret for each provider. This is done in the application.yml (or application.properties) file using the [Spring Security OAuth2 properties](https://docs.spring.io/spring-security/reference/servlet/oauth2/login/core.html). You can see the example configuration in the Demo Project's `application.yml` file.
748
762
749
763
764
+
## GDPR Compliance
765
+
766
+
The framework provides opt-in GDPR compliance features to help your application meet European data protection requirements. These features are **disabled by default** and must be explicitly enabled.
767
+
768
+
### Enabling GDPR Features
769
+
770
+
Add the following to your `application.yml`:
771
+
772
+
```yaml
773
+
user:
774
+
gdpr:
775
+
enabled: true # Master toggle for all GDPR features
776
+
exportBeforeDeletion: true # Automatically export data before deletion
6. **Publishes `UserDeletedEvent`** for post-deletion processing
830
+
7. **Invalidates all sessions** across all devices
831
+
8. **Logs out** the current session
832
+
833
+
**Important**: This performs a hard delete. Ensure you have the `UserPreDeleteEvent` listener configured (see [Handling User Account Deletion](#handling-user-account-deletion-and-profile-cleanup)) to clean up related data.
834
+
835
+
### Consent Management
836
+
837
+
Track user consent for various purposes (marketing, analytics, data processing, etc.):
All consent changes are recorded in the audit log with timestamps, IP addresses, and user agent information.
870
+
871
+
### Extending GDPR Exports
872
+
873
+
To include your application's custom data in GDPR exports, implement the `GdprDataContributor` interface:
874
+
875
+
```java
876
+
@Component
877
+
public class OrderDataContributor implements GdprDataContributor {
878
+
879
+
private final OrderRepository orderRepository;
880
+
881
+
public OrderDataContributor(OrderRepository orderRepository) {
882
+
this.orderRepository = orderRepository;
883
+
}
884
+
885
+
@Override
886
+
public String getDataKey() {
887
+
return "orders"; // Key in the export JSON
888
+
}
889
+
890
+
@Override
891
+
public Object contributeData(User user) {
892
+
// Return data to include in export (will be serialized to JSON)
893
+
return orderRepository.findByUserId(user.getId())
894
+
.stream()
895
+
.map(this::toExportDto)
896
+
.toList();
897
+
}
898
+
899
+
@Override
900
+
public void prepareForDeletion(User user) {
901
+
// Clean up data before user deletion (runs within transaction)
902
+
// WARNING: Only delete LOCAL database data here, not external APIs
903
+
orderRepository.deleteByUserId(user.getId());
904
+
}
905
+
906
+
private OrderExportDto toExportDto(Order order) {
907
+
// Map to DTO for export
908
+
}
909
+
}
910
+
```
911
+
912
+
**Important**: The `prepareForDeletion()` method runs within the same database transaction as user deletion. Only perform local database operations here. For external API cleanup, use a `UserDeletedEvent` listener instead.
913
+
914
+
### GDPR Events
915
+
916
+
The framework publishes Spring events for GDPR operations:
917
+
918
+
| Event | When Published | Use Case |
919
+
|-------|----------------|----------|
920
+
| `UserPreDeleteEvent` | Before user deletion (in transaction) | Clean up related database records |
921
+
| `UserDeletedEvent` | After successful deletion | External API cleanup, notifications |
922
+
| `UserDataExportedEvent` | After data export | Audit logging, analytics |
0 commit comments