Skip to content

Commit f4f8cb3

Browse files
committed
add defaults
1 parent e1e1cda commit f4f8cb3

16 files changed

+1869
-717
lines changed

GDPR_COMPLIANCE_GUIDE.md

Lines changed: 111 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,125 @@ Parse Server includes a comprehensive audit logging system that tracks:
3636
- Provides evidence that can support Article 32 (Security of Processing)
3737

3838
**Configuration:**
39+
40+
**Basic Configuration (File-based logging):**
41+
```javascript
42+
new ParseServer({
43+
// ... other options
44+
auditLog: {
45+
adapter: 'winston-file', // Optional - default is 'winston-file'
46+
adapterOptions: {
47+
auditLogFolder: './audit-logs', // Required to enable
48+
datePattern: 'YYYY-MM-DD', // Optional (default: daily rotation)
49+
maxSize: '20m', // Optional (default: 20MB per file)
50+
maxFiles: '14d', // Optional (default: 14 days retention)
51+
}
52+
}
53+
});
54+
```
55+
56+
**Advanced Configuration (with filtering):**
57+
```javascript
58+
new ParseServer({
59+
// ... other options
60+
auditLog: {
61+
adapter: 'winston-file',
62+
adapterOptions: {
63+
auditLogFolder: './audit-logs',
64+
datePattern: 'YYYY-MM-DD',
65+
maxSize: '20m',
66+
maxFiles: '14d',
67+
},
68+
logFilter: {
69+
// Log only specific event types
70+
events: ['USER_LOGIN', 'DATA_DELETE', 'SCHEMA_MODIFY'],
71+
72+
// Log only specific Parse classes
73+
includeClasses: ['_User', 'Order', 'Payment'],
74+
75+
// Exclude certain classes from logging
76+
excludeClasses: ['_Session', 'TempData'],
77+
78+
// Exclude master key operations (optional)
79+
excludeMasterKey: false,
80+
81+
// Filter by user roles
82+
includeRoles: ['admin', 'moderator'],
83+
84+
// Custom filter function for advanced logic
85+
filter: (event) => {
86+
// Example: Don't log system user operations
87+
return event.userId !== 'system';
88+
}
89+
}
90+
}
91+
});
92+
```
93+
94+
**Custom Adapter (e.g., S3 storage):**
3995
```javascript
96+
import { MyS3AuditLogAdapter } from './adapters/MyS3AuditLogAdapter';
97+
4098
new ParseServer({
4199
// ... other options
42100
auditLog: {
43-
auditLogFolder: './audit-logs', // Required to enable
44-
datePattern: 'YYYY-MM-DD', // Optional (default: daily rotation)
45-
maxSize: '20m', // Optional (default: 20MB per file)
46-
maxFiles: '14d', // Optional (default: 14 days retention)
101+
adapter: MyS3AuditLogAdapter, // Custom adapter instance
102+
adapterOptions: {
103+
bucket: 'my-audit-logs',
104+
region: 'eu-west-1',
105+
encryption: 'AES256',
106+
},
107+
logFilter: {
108+
events: ['USER_LOGIN', 'DATA_DELETE'],
109+
}
47110
}
48111
});
49112
```
50113

114+
**Pluggable Adapter Architecture:**
115+
116+
Parse Server's audit logging now uses a pluggable adapter pattern (similar to CacheAdapter, LoggerAdapter, etc.), allowing you to:
117+
118+
- **File-based storage** (default): Winston with daily rotation
119+
- **S3 storage**: Immutable logs via S3 bucket settings
120+
- **Database storage**: Store in MongoDB/PostgreSQL for easy querying
121+
- **External SIEM**: Forward to CloudWatch, Datadog, Splunk, etc.
122+
- **Custom implementation**: Implement `AuditLogAdapterInterface` for your needs
123+
124+
**Creating a Custom Adapter:**
125+
126+
```javascript
127+
// src/adapters/MyCustomAuditLogAdapter.js
128+
import { AuditLogAdapterInterface } from 'parse-server/lib/Adapters/AuditLog/AuditLogAdapterInterface';
129+
130+
export class MyCustomAuditLogAdapter extends AuditLogAdapterInterface {
131+
constructor(options) {
132+
super();
133+
this.options = options;
134+
// Initialize your storage backend
135+
}
136+
137+
isEnabled() {
138+
return true;
139+
}
140+
141+
async logUserLogin(event) {
142+
// Store login event to your backend
143+
await this.store(event);
144+
}
145+
146+
async logDataView(event) {
147+
await this.store(event);
148+
}
149+
150+
// ... implement other methods (logDataCreate, logDataUpdate, etc.)
151+
152+
async store(event) {
153+
// Your custom storage logic (S3, database, external service, etc.)
154+
}
155+
}
156+
```
157+
51158
### That's It
52159

53160
Parse Server provides **only** audit logging because:

resources/buildConfigDefinitions.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const parsers = require('../src/Options/parsers');
1313

1414
/** The types of nested options. */
1515
const nestedOptionTypes = [
16+
'AuditLogFilterOptions',
17+
'AuditLogOptions',
1618
'CustomPagesOptions',
1719
'DatabaseOptions',
1820
'FileUploadOptions',
@@ -25,11 +27,14 @@ const nestedOptionTypes = [
2527
'SecurityOptions',
2628
'SchemaOptions',
2729
'LogLevels',
30+
'WinstonFileAuditLogAdapterOptions',
2831
];
2932

3033
/** The prefix of environment variables for nested options. */
3134
const nestedOptionEnvPrefix = {
3235
AccountLockoutOptions: 'PARSE_SERVER_ACCOUNT_LOCKOUT_',
36+
AuditLogOptions: 'PARSE_SERVER_AUDIT_LOG_',
37+
AuditLogFilterOptions: 'PARSE_SERVER_AUDIT_LOG_FILTER_',
3338
CustomPagesOptions: 'PARSE_SERVER_CUSTOM_PAGES_',
3439
DatabaseOptions: 'PARSE_SERVER_DATABASE_',
3540
FileUploadOptions: 'PARSE_SERVER_FILE_UPLOAD_',
@@ -45,6 +50,7 @@ const nestedOptionEnvPrefix = {
4550
SchemaOptions: 'PARSE_SERVER_SCHEMA_',
4651
LogLevels: 'PARSE_SERVER_LOG_LEVELS_',
4752
RateLimitOptions: 'PARSE_SERVER_RATE_LIMIT_',
53+
WinstonFileAuditLogAdapterOptions: 'PARSE_SERVER_AUDIT_LOG_',
4854
};
4955

5056
function last(array) {
@@ -280,11 +286,13 @@ function inject(t, list) {
280286
if (elt.defaultValue) {
281287
let parsedValue = parseDefaultValue(elt, elt.defaultValue, t);
282288
if (!parsedValue) {
283-
for (const type of elt.typeAnnotation.types) {
284-
elt.type = type.type;
285-
parsedValue = parseDefaultValue(elt, elt.defaultValue, t);
286-
if (parsedValue) {
287-
break;
289+
if (elt.typeAnnotation && elt.typeAnnotation.types && Array.isArray(elt.typeAnnotation.types)) {
290+
for (const type of elt.typeAnnotation.types) {
291+
elt.type = type.type;
292+
parsedValue = parseDefaultValue(elt, elt.defaultValue, t);
293+
if (parsedValue) {
294+
break;
295+
}
288296
}
289297
}
290298
}

0 commit comments

Comments
 (0)