@@ -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+
4098new 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
53160Parse Server provides ** only** audit logging because:
0 commit comments