Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,17 @@
},
"additionalProperties": false
},
"audit": {
"type": "object",
"properties": {
"enabled": {
"description": "Log administration and moderation actions in a dedicated audit log file",
"type": "boolean",
"default": true
}
},
"additionalProperties": false
},
"anonymize_ip": {
"type": "boolean",
"default": false
Expand Down
3 changes: 3 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ log:
max_file_size: 12MB
max_files: 20

audit:
enabled: true # Log administration and moderation actions in a dedicated audit log file

anonymize_ip: false

# Tag every log line produced while handling a request with a request id, and with the authenticated user's username
Expand Down
3 changes: 3 additions & 0 deletions config/production.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ log:
max_file_size: 12MB
max_files: 20

audit:
enabled: true # Log administration and moderation actions in a dedicated audit log file

anonymize_ip: false

# Tag every log line produced while handling a request with a request id, and with the authenticated user's username
Expand Down
17 changes: 17 additions & 0 deletions packages/tests/src/api/server/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ describe('Test logs', function () {
expect(logsString.includes('video 10')).to.be.true
expect(logsString.includes('video 11')).to.be.false
})

it('Should not log audit entries when the audit log is disabled', async function () {
this.timeout(60000)

await killallServers([ server ])

await server.run({ log: { audit: { enabled: false } } })

const now = new Date()

await server.videos.upload({ attributes: { name: 'video 12' } })
await waitJobs([ server ])

const body = await logsCommand.getAuditLogs({ startDate: now })

expect(body).to.have.lengthOf(0)
})
})

describe('When creating log from the client', function () {
Expand Down
2 changes: 2 additions & 0 deletions server/core/helpers/audit-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const auditLogger = createLogger({
})

function auditLoggerWrapper (domain: string, user: string, action: AUDIT_TYPE, entity: EntityAuditView, oldEntity: EntityAuditView = null) {
if (CONFIG.LOG.AUDIT.ENABLED !== true) return

let entityInfos: object

if (action === AUDIT_TYPE.UPDATE && oldEntity) {
Expand Down
1 change: 1 addition & 0 deletions server/core/initializers/checker-before-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function checkMissedConfig () {
'log.rotation.enabled',
'log.rotation.max_file_size',
'log.rotation.max_files',
'log.audit.enabled',
'log.anonymize_ip',
'log.tag_requests',
'log.log_ping_requests',
Expand Down
3 changes: 3 additions & 0 deletions server/core/initializers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ const CONFIG = {
MAX_FILE_SIZE: bytes.parse(config.get<string>('log.rotation.max_file_size')),
MAX_FILES: config.get<number>('log.rotation.max_files')
},
AUDIT: {
ENABLED: config.get<boolean>('log.audit.enabled')
},
ANONYMIZE_IP: config.get<boolean>('log.anonymize_ip'),
TAG_REQUESTS: config.get<boolean>('log.tag_requests'),
LOG_PING_REQUESTS: config.get<boolean>('log.log_ping_requests'),
Expand Down
Loading